Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
rjackman1959
Yak Posting Veteran
60 Posts |
Posted - 2009-01-13 : 20:25:35
|
OK I’m pretty new to SQL and I am trying to call a stored procedure from Exec passing 2 params. I don’t have a problem with 1, but I’m not sure how to send 2. I am getting an “Unclosed quotation mark after the character string” error. Any help would be appreciated. Thanks in advanceSub Get_Settlements()Dim command As StringDim parm1 As Stringparm1 = Range("F5").ValueDim parm2 As Stringparm2 = Range("F6").Value' Create a connection object.Set SuiteConn = New ADODB.Connection' Provide the connection string.Dim strConn As String'Use the SQL Server OLE DB Provider.strConn = "PROVIDER=SQLOLEDB;"'Connect to the database on remote server.strConn = strConn & "Data Source=IP; Initial Catalog=DATABASE;"'Use an integrated login.strConn = strConn & " INTEGRATED SECURITY=sspi;"'Now open the connection.SuiteConn.Open strConn' Create a recordset object.Dim rsCas As ADODB.RecordsetSet rsCas = New ADODB.Recordset'MsgBox parmWith rsCas ' Assign the Connection object. .ActiveConnection = SuiteConn ' Extract the required records. .Open "wynne_get_settlements '" & parm1 & ", " & parm2 ' Copy the records into cell A11 on Sheet1. Sheet1.Range("A11").CopyFromRecordset rsCas .CloseEnd WithSuiteConn.CloseSet rsCas = NothingSet RSuiteConn = NothingEnd Sub |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-13 : 22:45:53
|
quote: Originally posted by rjackman1959 OK I’m pretty new to SQL and I am trying to call a stored procedure from Exec passing 2 params. I don’t have a problem with 1, but I’m not sure how to send 2. I am getting an “Unclosed quotation mark after the character string” error. Any help would be appreciated. Thanks in advanceSub Get_Settlements()Dim command As StringDim parm1 As Stringparm1 = Range("F5").ValueDim parm2 As Stringparm2 = Range("F6").Value' Create a connection object.Set SuiteConn = New ADODB.Connection' Provide the connection string.Dim strConn As String'Use the SQL Server OLE DB Provider.strConn = "PROVIDER=SQLOLEDB;"'Connect to the database on remote server.strConn = strConn & "Data Source=IP; Initial Catalog=DATABASE;"'Use an integrated login.strConn = strConn & " INTEGRATED SECURITY=sspi;"'Now open the connection.SuiteConn.Open strConn' Create a recordset object.Dim rsCas As ADODB.RecordsetSet rsCas = New ADODB.Recordset'MsgBox parmWith rsCas ' Assign the Connection object. .ActiveConnection = SuiteConn ' Extract the required records. .Open "wynne_get_settlements '" & parm1 & "', " & parm2 ' Copy the records into cell A11 on Sheet1. Sheet1.Range("A11").CopyFromRecordset rsCas .CloseEnd WithSuiteConn.CloseSet rsCas = NothingSet RSuiteConn = NothingEnd Sub
missed a ' |
 |
|
|
rjackman1959
Yak Posting Veteran
60 Posts |
Posted - 2009-01-14 : 07:41:40
|
| Thanks VisakhCan you show me where it goes please? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-14 : 08:18:17
|
| i've modified it in reply see below.Open "wynne_get_settlements '" & parm1 & "', " & parm2 |
 |
|
|
rjackman1959
Yak Posting Veteran
60 Posts |
Posted - 2009-01-14 : 10:55:37
|
| Thank You very much this will help. I was just putting into 1 parm and then splitting it up in SQL, but this is much cleaner |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-14 : 11:57:46
|
| cheers |
 |
|
|
|
|
|