VBdotnet2005
asked on
Northwind database - ERROR - Syntax error converting the varchar value 'MYINPUT' to a column of data type int.
I keep gettig error : Syntax error converting the varchar value 'ANTON' to a column of data type int. What does it means?
There is a lot of "IF" in my code. How would I use Select case in this case? Your help is greatly appreciated.
Private Sub ToolStripButton1_Click(ByV al sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
Dim connectionString As String = "Data Source=SUPERMAN;Initial Catalog=Northwind;Integrat ed Security=True"
Dim con As New SqlConnection(connectionSt ring)
Dim selectSQL As String = "select *from orders where orderid = '" & Me.ToolStripTextBox1.Text & "'"
Dim da As New SqlDataAdapter(selectSQL, con)
Dim ds As New DataSet
Dim Id As String = Me.ToolStripTextBox1.Text. Trim
If Me.ToolStripTextBox1.Text = Nothing Then
MessageBox.Show("Please enter OrderId", "Empty Field", _
MessageBoxButtons.OK, MessageBoxIcon.Information )
End If
If Me.ToolStripComboBox1.Sele ctedIndex = 1 Then
If Regex.IsMatch(Id, "^\d{5}$") Then
da.Fill(ds, "orders")
If ds.Tables("orders").Rows.C ount = 0 Then
MsgBox("Record not found")
Else
Me.DataGridView3.DataSourc e = ds.Tables("orders")
End If
Else
MsgBox("Id needs to be a 5 digit number only")
End If
End If
If Me.ToolStripComboBox1.Sele ctedIndex = 0 Then
If Regex.IsMatch(Id, "^\w{5}$") Then ' -------------------------- ---SUPPOSE D TO BE 5 CHARACTOR LONG
da.Fill(ds, "customers") ************************** ERROR HERE Syntax error converting the varchar value 'ANTON' to a column of data type int.
If ds.Tables("customers").Row s.Count = 0 Then
MsgBox("CustomerId not found")
Else
Me.DataGridView3.DataSourc e = ds.Tables("Customers")
End If
MsgBox("Please enter CustomerID")
End If
End If
End Sub
There is a lot of "IF" in my code. How would I use Select case in this case? Your help is greatly appreciated.
Private Sub ToolStripButton1_Click(ByV
Dim connectionString As String = "Data Source=SUPERMAN;Initial Catalog=Northwind;Integrat
Dim con As New SqlConnection(connectionSt
Dim selectSQL As String = "select *from orders where orderid = '" & Me.ToolStripTextBox1.Text & "'"
Dim da As New SqlDataAdapter(selectSQL, con)
Dim ds As New DataSet
Dim Id As String = Me.ToolStripTextBox1.Text.
If Me.ToolStripTextBox1.Text = Nothing Then
MessageBox.Show("Please enter OrderId", "Empty Field", _
MessageBoxButtons.OK, MessageBoxIcon.Information
End If
If Me.ToolStripComboBox1.Sele
If Regex.IsMatch(Id, "^\d{5}$") Then
da.Fill(ds, "orders")
If ds.Tables("orders").Rows.C
MsgBox("Record not found")
Else
Me.DataGridView3.DataSourc
End If
Else
MsgBox("Id needs to be a 5 digit number only")
End If
End If
If Me.ToolStripComboBox1.Sele
If Regex.IsMatch(Id, "^\w{5}$") Then ' --------------------------
da.Fill(ds, "customers") **************************
If ds.Tables("customers").Row
MsgBox("CustomerId not found")
Else
Me.DataGridView3.DataSourc
End If
MsgBox("Please enter CustomerID")
End If
End If
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.