
SQL server varchar data type is not readable in VB
In my table, there are several columns. One of them is a
varchar column.
The function of Sub startcon below is to connect to
database. The Sub test is called after connection exists.
Private Sub startcon()
dim x as string
DBEngine.DefaultType = dbUseODBC
Set pbws = DBEngine.Workspaces(0)
x = "ODBC;DRIVER=SQL server; UID=xxx; PWD=aaa; SERVER=SRV; DATABASE=abc"
'pbcn is public variable
Set pbcn = pbws.OpenConnection("", dbDriverNoPrompt,False, x)
End Sub
Private Sub test()
dim x as String, myrecord is Recordset
dim s as String
x = "select * from mytab"
Set myrecord = pbcn.OpenRecordset(x, dbOpenDynaset)
If myrecord.RecordCount = 0 Then
Exit Sub
End If
debug.print myrecord!remark
If IsNull(myrecord!remark) then
debug.print "yes"
Else
debug.print "no"
End If
s = myrecord!remark
End Sub
Anita Hery
Quote:
>From: Val Mazur
>Anita,
>What is your connection string?
>--
>Val Mazur
>Microsoft MVP
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!