Usage of ADODB.Command

Results 1 to 2 of 2

Thread: Usage of ADODB.Command

  1. #1
    Vinu Guest

    Default Usage of ADODB.Command

    Sir, <BR><BR> I am using ADODB.Command, for insertion. Code like..<BR><BR>&#062;&#062; line 1 set Cmd = Server.CreateObject("ADODB.Command") <BR>&#062;&#062; line 2 set prmName = server.CreateObject("ADODB.Parameter") <BR>&#062;&#062; line 3 Sql="Insert into Sample_Table(Name,Age) values(?, 10)"<BR>&#062;&#062; line 4 Cmd.CommandText=Sql<BR>&#062;&#062; line 5 set Cmd.ActiveConnection=Conn1<BR>&#062;&#062; line 6 set prmName = cmd.CreateParameter("prm1",adVarChar , 1)<BR>&#062;&#062; line 7 cmd.Parameters.Append prmName<BR>&#062;&#062; line 8 prmName.Value = "David Dhawan" <BR>&#062;&#062; line 9 Cmd.Execute<BR><BR>But i am getting "The application has improperly defined a Parameter object." in line number 7.What&#039s wrong with this code?. Give me brief idea about the usage of ADODB.Command.<BR><BR>Thanking u,<BR>Vinu Gopinath.

  2. #2
    Vinay P Singh Guest

    Default RE: Usage of ADODB.Command

    Hi Vinu!!<BR><BR>The answer to your problem lies in the fact that ASP does not recognize Enumerated constants such as adVarChar or adInteger.<BR>You have to instead write the value directly. Use 200 in place of advarChar.<BR><BR>The following code works fine for integer input parameter....<BR><BR><BR>dim cmd<BR>dim conn1<BR>dim prmname<BR>dim sql<BR><BR>set conn1 = server.CreateObject("ADODB.connection")<BR>conn1.o pen "Provider=MSDAORA;Data Source=try;User ID=outlook;password=outlook"<BR>Set cmd = server.CreateObject("ADODB.Command")<BR>Set prmName = server.CreateObject("ADODB.Parameter")<BR>Sql = "Insert into section_expert_link (section_id,Expert_id) values(?,2)"<BR>cmd.CommandText = Sql<BR>Set cmd.ActiveConnection = conn1<BR>Set prmName = cmd.CreateParameter("prm1", 3, 1)<BR>cmd.Parameters.Append prmName<BR>prmName.Value =2<BR>cmd.Execute<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts