SqlClient Data Provider Error

  • Thread starter Thread starter Kimbo
  • Start date Start date
K

Kimbo

Hi

I am receiving the following error message in my program.

Error: .Net SqlClient Data Provider: Syntax error converting the
nvarchar value '00C1' to a column of data type int.

I cant seem to work why I get this message or what it means, I have
tested my query against my database and it is fine. When I remove the
Try/Catch the error appears to be occurring with da.Fill(ds,
"Keyholder") part of my code.

Code listed below.

Any help would be appreciated.


Private Sub btnUsers_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUsers.Click

Dim connSql As New SqlClient.SqlConnection(oDatabase.ConnectionString)
Dim ds As New DataSet
Dim strQuery As String

Try
strQuery = "SELECT UserName, " & _
" Phone, Mobile, OrderID " & _
" FROM Keyholders " & _
" WHERE Keyholders.ClientID = " &
Me.txtAccNo.Text & " ORDER BY OrderID"

Dim da As New SqlClient.SqlDataAdapter(strQuery, connSql)
da.Fill(ds, "Keyholder")

'Check for valid Acc number
If Me.BindingContext(ds, "Clients").Count = 0 Then
MsgBox("No Users Found For " & Me.txtAccNo.Text,
MsgBoxStyle.Critical, "Data Error")
Exit Sub
End If

dbGridKeyholders.DataSource = ds.Tables(0)
dbGridKeyholders.DataMember = "Keyholder"

Catch ex As Exception
MsgBox("Error: " & ex.Source & ": " & ex.Message,
MsgBoxStyle.OKOnly, "Data Error")
End Try
Me.btnUsers.Enabled = False
Me.GroupBox2.Visible = True
End Sub

Regards
Kim
 
Hi,

Sounds to me that adapter creates an int column for nvarchar field.
Can you call FillSchema instead of Fill and check what columns are created?
 
Back
Top