PC Review


Reply
Thread Tools Rate Thread

Re: How do you capture the value of a local variable from SQL Server?

 
 
Brendan Reynolds
Guest
Posts: n/a
 
      25th Mar 2008
"acraft" <u42371@uwe> wrote in message news:81a4f7f2e7eca@uwe...
> How do you capture this variable from SQL Server?
> Example of T-SQL code:
>
> declare @strVariable varchar(20)
> set @strVariable = 'This was a success...'
> select @strVariable as NEW_FIELD
>
> How do I capture the returned value "This was a success..." without
> creating
> a temporary table on the SQL Server? I am using MS Access and trying to
> use
> the ADO.Recordset.
>
>
> Should I use a different method? Any suggestions or sample code?
>



Something like this should work. Substitute your own connection string and
stored procedure name of course.

Public Sub TestSub()

Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset

Set cnn = New ADODB.Connection
cnn.ConnectionString = "Provider=SQLNCLI.1;" & _
"Integrated Security=SSPI;" & _
"Persist Security Info=False;" & _
"Initial Catalog=test;" & _
"Data Source=K9\SQLEXPRESS"
cnn.Open
Set rst = New ADODB.Recordset
rst.Open "test", cnn, , , adCmdStoredProc
Debug.Print rst.Fields(0).Value
rst.Close
cnn.Close


End Sub

--
Brendan Reynolds

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Threading and outer-variable semantics, local variables capture inanonymous methods--why? RayLopez99 Microsoft C# .NET 3 15th Feb 2010 10:22 AM
VBA IIf(myCell.Value = Array(myCell2(1).Value, myCell2(2).Value,myCell2(3).Value,myCell2(4).Value) ,"OK","No Match) EagleOne@discussions.microsoft.com Microsoft Excel Programming 2 24th Apr 2009 11:25 PM
Re: How do you capture the value of a local variable from SQL Server? Tom van Stiphout Microsoft Access VBA Modules 1 25th Mar 2008 03:41 PM
Re: Question??? You know when you double click in a username field you see your previous entries? How do you reset this so you can see your entries again. Thorsten Matzner Windows XP New Users 0 5th Jun 2004 04:34 PM
Question??? You know when you double click in a username field you see your previous entries? How do you reset this so you can see your entries again. =?Utf-8?B?Y2hyaXM=?= Windows XP General 1 3rd Jun 2004 08:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:12 AM.