Groups | Blog | Home
all groups > vb.net data > june 2005 >

vb.net data : Returning contents of a Field from DSN


Rob
6/13/2005 7:10:24 PM
I am trying to connect to a proprietary database using a DSN

If the following were to work... how would I store the contents of Customer
from the Select statement below to a variable ?

sConnString = "DSN=TestDSN"

oODBCConnection = New Odbc.OdbcConnection(sConnString)

strSQL = "Select Customer from Orders where Order = " & sOrdNum

sODBCCommand = New OdbcCommand(strSQL)

oODBCConnection.Open()

Ken Tucker [MVP]
6/13/2005 7:55:00 PM
Hi,

ODBCCommand.executescalar

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdataodbcodbccommandclassexecutescalartopic.asp

Ken
--------------------
[quoted text, click to view]
I am trying to connect to a proprietary database using a DSN

If the following were to work... how would I store the contents of Customer
from the Select statement below to a variable ?

sConnString = "DSN=TestDSN"

oODBCConnection = New Odbc.OdbcConnection(sConnString)

strSQL = "Select Customer from Orders where Order = " & sOrdNum

sODBCCommand = New OdbcCommand(strSQL)

oODBCConnection.Open()


Rob
6/13/2005 8:34:42 PM
Hi Ken,

Thanks for responding...

I tried adding...
sCustomer = sODBCCommand.ExecuteScalar("Customer")

but nothing was returned

Rob


[quoted text, click to view]

Ken Tucker [MVP]
6/14/2005 3:35:06 AM
Hi,

I dont see where you set the commands connection property. This
should work



Dim sODBCCommand as new ODBCCommand(strSql,oODBCConnection)

oODBCConnection.Open()

Dim strResult as string

strResult = oODBCCommand.ExecuteScalar().tostring

oODBCConnection.Close()


Ken
-----------------

[quoted text, click to view]
Hi Ken,

Thanks for responding...

I tried adding...
sCustomer = sODBCCommand.ExecuteScalar("Customer")

but nothing was returned

Rob


[quoted text, click to view]


AddThis Social Bookmark Button