Exec Stored Proc with Parameters

S

SlowGirl

I am trying to pass three values from an access form to a where statement in
a SQL Stored Procedure. I'm new at this; what am I doing wrong? Also, is
there a way to write the connection string so it prompts users for their own
username/password? The pasted code in on the AfterUpdate event of a text
box. Thanks in advance
------------------

Dim cmd As ADODB.Command
Set cmd = New ADODB.Command
cmd.ActiveConnection = "PROVIDER=SQLOLEDB;Data Source=MyServer;Initial
Catalog=MyDb;User Id=user;Password=pword"
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "spUpdateList"

Dim strEID As String
Dim strFieldName As String
Dim strNewValue As String

strFieldName = "Title"
strEID = Trim(Me.txtEID.Value)
strNewValue = Me.txtTitleUpdate.Value

cmd.Execute , Array(strEID, strFieldName, strNewValue)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top