954,541 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

End of Statement Expected..... and this is really Unexpected... PLS HELP

Imports System.Data.SqlClient
Imports System.Data.SqlClient.SqlDataReader
Imports System.Data.SqlClient.SqlConnection


Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Inherits System.Windows.Forms.Form

    Dim myConnection As New SqlConnection
    Dim myCommand As New SqlCommand
    Dim ds As New DataSet
    Dim cmdtext As Integer
    Dim action As String
    Dim view As DataView
    Dim dr As SqlDataReader
        Dim cmdtext As String
        Dim cmd As New SqlCommand

        myConnection = New SqlConnection("Data Source=RUSHIKES-1A6789\SQLEXPRESS;Initial Catalog=AutoParts;Integrated Security=True")

Try
            myConnection.Open()
            myCommand.Connection = myConnection
            myCommand.CommandText = "Insert Into customer(c_id,c_name,c_add,c_phno1,c_phno2,c_phno3,c_email) values ("& txtb1.text",'"& txtb2.text"','"& txtb3.text"',"& txtb4.text","& txtb5.text","& txtb6.text",'"& txtb7.text"')"
            myCommand.ExecuteNonQuery()

        Catch ex As Exception
            MessageBox.Show("Error while inserting record on table..." & ex.Message, "Insert Records")
        Finally
            myConnection.Close()
        End Try

        fill()
        DataGridView1.Refresh()
End Sub
End Class

----------------------------------------------------------------------------------------
Code is throwing Error on Line :
End of Statement Expected

myCommand.CommandText = "Insert Into customer(c_id,c_name,c_add,c_phno1,c_phno2,c_phno3,c_email) values ("& txtb1.text",'"& txtb2.text"','"& txtb3.text"',"& txtb4.text","& txtb5.text","& txtb6.text",'"& txtb7.text"')"

----------------------------------------------------------------------------------------

Guys Please Help
Thanx in Advance

rick.eavans
Newbie Poster
5 posts since Dec 2010
Reputation Points: 10
Solved Threads: 0
 

For number values -> "& text1.text &"
For string values -> '"& text1.text &"'
For date values -> #"& text1.text &"#
hope u have set data type for phone no. as number(double)


"Insert Into customer(c_id,c_name,c_add,c_phno1,c_phno2,c_phno3,c_email) values ('"& txtb1.text &"','"& txtb2.text &"','"& txtb3.text &"',"& txtb4.text &","& txtb5.text &","& txtb6.text &",'"& txtb7.text &"')"

good luck!!

DivideByZero
Newbie Poster
1 post since Dec 2010
Reputation Points: 10
Solved Threads: 1
 

Thanx dude... it worked !!

rick.eavans
Newbie Poster
5 posts since Dec 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: