Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I am so glad that I found your site, it is an excellent resource and has helped me greatly..."

Geography

Where in the world do Tek-Tips members come from?

passing string parameter via VB.ODBC.SQLServer

LTusing (TechnicalUser)
12 Feb 07 13:40
I am trying to call a SQLServer 2000 proc to update .adp record columns.  We are able to complete task for data and int columns but have run into difficulty in passing nvarchar and char columns.  We are receiving error "Cannot open database"mydatabase" requested in login.  Login Failed.  The code is as follows for table_Randomization (pt_id(int), rand_no(char), rand_dt(datetime).  The VB procedure is as follows:

Private Sub UpdateRandomization_Record_Click()

Dim strMsg As String
Dim strOK As String
Dim cnn As ADODB.Connection
Dim cmd As ADODB.Command
Dim SQLServer As ADODB.Connection
Dim rstRandomization As New ADODB.Recordset
Dim strRandomization As String
Dim param1 As ADODB.Parameter
Dim param2 As ADODB.Parameter
Dim param3 As ADODB.Parameter
Dim param4 As ADODB.Parameter

Set SQLServer = New ADODB.Connection
SQLServer.Provider = "SQLOLEDB"
SQLServer.ConnectionString = "Data Source=PEDSBOT;Initial Catalog=fas.adhd.blind;Trusted_Connection=Yes"
SQLServer.CommandTimeout = 0
SQLServer.ConnectionTimeout = 300
SQLServer.Open

With cmd
    .ActiveConnection = cnn
    .CommandText = "dbo.procupdate_Randomization_1"
    .CommandType = adCmdStoredProc
End With

Set param1 = cmd.CreateParameter(, adInteger, adParamInput)
    cmd.Parameters.Append param1
    param1.Value = pt_id
Set param2 = cmd.CreateParameter(, adInteger, adParamInput)
    cmd.Parameters.Append param2
    param2.Value = Me.pt_id
Set param3 = cmd.CreateParameter(, adChar, adParamInput, 3)
    cmd.Parameters.Append param3
    param3.Value = Me.rand_no
Set param4 = cmd.CreateParameter(, adDBDate, adParamInput)
    cmd.Parameters.Append param4
    param4.Value = Me.rand_dt

cmd.Execute
Debug.Print rstRandomization(0)
rstRandomization.Close

End Sub


Thank You!

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close