Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Database Access / June 2006



Tip: Looking for answers? Try searching our database.

passing parameter from vb 6.0 code to sql stored procedure

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pmud - 26 Jun 2006 20:05 GMT
Hi,

I was earlier using recordset and query in my vb code. But since I want to
implement transactions in my code to avoid any errors, I need to use sql
stored procedure instead of sql query. Below is the code i tried to use, but
i get error message: "Mehthod or sub not found" and the CreateParanmeter ia
highlighted in the code:

Below is my code. Please help me correct it:
Dim cn As ADODB.Connection
   Dim rsCheck As ADODB.Recordset
   
   Dim cmd As ADODB.Command
 
   Dim rsRecCount As Integer  ' For counting records in a record set
   
   Set cn = New ADODB.Connection
   cn.ConnectionString = strConnectionString
   cn.Open
   
   Set cmd = New ADODB.Command
   cmd.ActiveConnection = cn
   cmd.CommandType = adCmdStoredProc
   cmd.CommandText = "sp_ImgAlreadyUploaded"
   
   cmd.Parameters.Append (CreateParameter("strStudy_Date", adDate,
adParamInput, , " & strStudyDate & "))
   cmd.Parameters.Append (CreateParameter("strStudyTime", adDate,
adParamInput, , " & strStudyDate & "))
   cmd.Parameters.Append (CreateParameter("dteBirthDate ", adDate,
adParamInput, , " & strStudyDate & "))
 
  cmd.execute
 
   If rsRecCount > 0 Then
       
      intStudiesEarlierUploaded = intStudiesEarlierUploaded + 1
      n = m + 1
      RepeatLoop
   ElseIf rsRecCount = 0 Then
      CheckInDatabase()
   End If

Signature

pmud

Paul Clement - 27 Jun 2006 15:06 GMT
¤ Hi,
¤
¤ I was earlier using recordset and query in my vb code. But since I want to
¤ implement transactions in my code to avoid any errors, I need to use sql
¤ stored procedure instead of sql query. Below is the code i tried to use, but
¤ i get error message: "Mehthod or sub not found" and the CreateParanmeter ia
¤ highlighted in the code:
¤
¤ Below is my code. Please help me correct it:
¤ Dim cn As ADODB.Connection
¤     Dim rsCheck As ADODB.Recordset
¤    
¤     Dim cmd As ADODB.Command
¤  
¤     Dim rsRecCount As Integer  ' For counting records in a record set
¤    
¤     Set cn = New ADODB.Connection
¤     cn.ConnectionString = strConnectionString
¤     cn.Open
¤    
¤     Set cmd = New ADODB.Command
¤     cmd.ActiveConnection = cn
¤     cmd.CommandType = adCmdStoredProc
¤     cmd.CommandText = "sp_ImgAlreadyUploaded"
¤    
¤     cmd.Parameters.Append (CreateParameter("strStudy_Date", adDate,
¤ adParamInput, , " & strStudyDate & "))
¤     cmd.Parameters.Append (CreateParameter("strStudyTime", adDate,
¤ adParamInput, , " & strStudyDate & "))
¤     cmd.Parameters.Append (CreateParameter("dteBirthDate ", adDate,
¤ adParamInput, , " & strStudyDate & "))
¤  
¤    cmd.execute
¤  
¤     If rsRecCount > 0 Then
¤        
¤        intStudiesEarlierUploaded = intStudiesEarlierUploaded + 1
¤        n = m + 1
¤        RepeatLoop
¤     ElseIf rsRecCount = 0 Then
¤        CheckInDatabase()
¤     End If

CreateParameter is a method of the Command object. If you don't specify the Command object Visual
Basic won't know what it is.

Paul
~~~~
Microsoft MVP (Visual Basic)
pmud - 27 Jun 2006 15:20 GMT
Thanks Paul.
Signature

pmud

> ¤ Hi,
> ¤
[quoted text clipped - 45 lines]
> ~~~~
> Microsoft MVP (Visual Basic)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.