Solved

Northwind database - ERROR - Syntax error converting the varchar value 'MYINPUT' to a column of data type int.

Posted on 2006-06-13
1
216 Views
Last Modified: 2010-04-23
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(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click

        Dim connectionString As String = "Data Source=SUPERMAN;Initial Catalog=Northwind;Integrated Security=True"
        Dim con As New SqlConnection(connectionString)
        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.SelectedIndex = 1 Then

            If Regex.IsMatch(Id, "^\d{5}$") Then
                da.Fill(ds, "orders")
                If ds.Tables("orders").Rows.Count = 0 Then
                    MsgBox("Record not found")
                Else
                    Me.DataGridView3.DataSource = ds.Tables("orders")
                End If
            Else
                MsgBox("Id needs to be a 5 digit number only")
            End If


        End If

        If Me.ToolStripComboBox1.SelectedIndex = 0 Then
            If Regex.IsMatch(Id, "^\w{5}$") Then  ' -----------------------------SUPPOSED 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").Rows.Count = 0 Then
                    MsgBox("CustomerId not found")
                Else
                    Me.DataGridView3.DataSource = ds.Tables("Customers")


                End If

                MsgBox("Please enter CustomerID")


            End If

        End If

       



    End Sub
0
Comment
Question by:VBdotnet2005
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 4

Accepted Solution

by:
imperial_p79 earned 500 total points
ID: 16900325
I am assuming that your Me.ToolStripTextBox1.Text value is 'ANTON'. In the query you are comparing this value against OrderID = 'Me.ToolStripTextBox1.Text' which is an integer field.

so change the query to

SELECT * FROM ORDERS WHERE CUSTOMERID=  '" & Me.ToolStripTextBox1.Text & "'"

Hope this helps

For select case statement, the syntax follows as

        Select Case <variablename>
            Case "value1"
            Case "value2"
            Case Else

        End Select
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question