Forum Discussion

Thirumaleswara's avatar
Thirumaleswara
Regular Visitor
2 years ago

Procedure or function 'storedprocname' expects parameter '@Param1', which was not supplied.

 

Hello Community,

Even when supply parameter,  get error as " Procedure or function 'storedprocname' expects parameter '@Param1', which was not supplied."

Below is the code snip.

Thank you 

 

var AConnection, RecSet, Cmd, Prm;
// Create a new Connection object
AConnection = ADO.CreateConnection();
// Specify the connection string
AConnection.ConnectionString = "Provider=MSOLEDBSQL.1;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
// Activate the connection
AConnection.Open();

// Create a new Command object
Cmd = ADO.CreateCommand();

// Specify the connection
Cmd.ActiveConnection = AConnection;

// Specify command type and text
Cmd.CommandType = adCmdStoredProc;

Cmd.CommandText = "StoredProcName";

// Create a new parameter
Prm = Cmd.CreateParameter("@Param1", adDBDate, adParamInput, "20220101");
Cmd.Parameters.append(Prm);

// Execute the command
RecSet = Cmd.Execute();

 

 

 

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    If you're using ODBC Microsoft.Jet.OLEDB.4.0, then creating a parameter will be e.g. 

     

     

    var Prm = Cmd.CreateParameter("MyParam", adChar, adParamInput, 20, "Canada");

     

     

    The syntax of the command’s query depends on the ODBC you use. For instance, if you work with Microsoft.Jet.OLEDB.4.0 provider, you can specify parameters by their names. Other ODBC may use question marks (?) as parameter placeholders. Some ODBC may support both techniques, or use their own syntax.

     

    Search the database provider's documentation for the ODBC you are using.