# ADO & NULL

Posted by Ariel on April 21, 1999 at 08:46:44:

I have a procedure,I hope it can access from SQL with ADO,if a value of field
is NULL,then it's be space,but I can only get the value first,after the first,
I get NULL always.Why?

Global cn As New ADODB.Connection
Global quescmd As New ADODB.Command
Global quesrec As New ADODB.Recordset

.Private Main()
. Dim parm As ADODB.Parameter
. Dim conn As String
.
. conn = "driver={SQL Server};server=ntserver1;uid=sa;pwd=;database=cbt"
. With cn
. .ConnectionString = conn
. .ConnectionTimeout = 10
. .Open
. End With
.
. Set quescmd = New ADODB.Command
. quescmd.ActiveConnection = cn
. With quescmd
. .CommandText = "select * from cbt_question where question_id=?"
. .CommandType = adCmdText
. .CommandTimeout = 15
. End With
. Set parm = New ADODB.Parameter
. With parm
. .Type = adChar
. .Size = 8
. .Direction = adParamInput
. quescmd.Parameters.Append parm
. End With
.End Sub
.
.Private Sub DispQues(quesid As String)
. Dim i As Integer
. Dim midstr As String
.
. quescmd.Parameters(0).Value = quesid
. Set quesrec = quescmd.Execute()
.
. If quesrec.EOF = True Then
. MsgBox "Not exist any question"
. Exit Sub
. End If
.
. QUESLABEL.Caption = quesrec!question_desc.GetChunk(200) 'All fields are Text in SQL
. For i=1 To 3
. if IsNull(quesrec.fields(i).getchunk(200)) Then 'here is correct,it have a value
. Label1(i).Caption=""
. Else
. Label1(i).Caption=quesrec.fields(i).getChunk(200) 'here prompt the value is NULL
. Endif
. Next i
.End Sub

Follow Ups: