Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2006-06-13
1
Medium Priority
?
221 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 1500 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

596 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