recordcout when querying in sql = -1
hi,
i tried to migrate my database in access to sql server 2000,
at first i though it was working ok... but when i tried to query using RECORDCOUNT, it value returned -1.... but i tried it in ACCESS but its value is 1... is there such thing as recordcount = -1? is this an error? is there any alternatives? my sample code is this:
VB Code:
Set rs = New ADODB.Recordset
rs.Open "Select * from contacts where accountnum= '" & Trim(txtmain.Text) & "' or phone= '" & Trim(txtmain.Text) & "'", conn, 1, 3
MsgBox rs.RecordCount
If rs.RecordCount <> 0 Then
lblerr.Visible = False
If Len(Trim(rs!Company)) <> 0 Then
Me.txtcomp.Text = rs!Company
Else
Me.txtcomp.Text = "N.A."
End If
If Len(Trim(rs!Title)) <> 0 Then
Me.txttit.Text = rs!Title
Else
Me.txttit.Text = "N.A."
End If
If Len(Trim(rs!Contact)) <> 0 Then
Me.txtcontact.Text = rs!Contact
Else
txtcontact.Text = "N.A."
End If
If Len(Trim(rs!Department)) <> 0 Then
Me.txtdept.Text = rs!Department
Else
txtdept.Text = "N.A."
End If
If Len(Trim(rs!mobnum)) <> 0 Then
Me.txtmobnum.Text = rs!mobnum
Else
txtmobnum.Text = "N.A."
End If
If Len(Trim(rs!Email)) <> 0 Then
Me.txtemail.Text = rs!Email
Else
txtemail.Text = "N.A."
End If
If Len(Trim(rs!Phone)) <> 0 Then
txtconnum.Text = rs!Phone
Else
txtconnum.Text = "N.A."
End If
If Len(Trim(rs!extension)) <> 0 Then
txtextension.Text = rs!extension
Else
txtextension.Text = "N.A."
End If
If Len(Trim(rs!contactstat)) <> 0 Then
txtidstat.Text = rs!contactstat
Else
txtidstat.Text = "N.A."
End If
If Len(Trim(rs!website)) <> 0 Then
txtwebsite.Text = rs!website
Else
txtwebsite.Text = "N.A."
End If
If Len(Trim(rs!accountnum)) <> 0 Then
txtaccountnum.Text = rs!accountnum
Else
txtaccountnum.Text = "N.A."
End If
If Len(Trim(rs!recordmanager)) <> 0 Then
txtam.Text = rs!recordmanager
Else
txtam.Text = "Ronald San Diego"
End If
Else
lblerr.Visible = True
End If
rs.Close
Set rs = Nothing
Re: recordcout when querying in sql = -1
Here is a thread about that issue: LINK