0

when I try to insert values I got this error:
I Used this code

myConnection = New SqlConnection(connectionstring)
        myConnection.Open()

        Try

            Dim insert1 As SqlCommand = New SqlCommand("INSERT INTO [VBP].[dbo].[Return_Total] ([RGN0],[Date] ,[Totalamount],[User_Id],[C_NIC],[Comments],[Bill_No]) values ('" & Val(TextBox2.Text) & "','" & DateTimePicker1.Value.Date & "','" & TextBox4.Text & "','" & TextBox6.Text & "','" & TextBox3.Text & "','" & TextBox5.Text & "','" & Val(TextBox8.Text) & "'", myConnection)
            insert1.ExecuteNonQuery()
            insert1.Cancel()
            MessageBox.Show("New Data has Added")

        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical, "ERROR")
        Finally
        End Try
        myConnection.Close()

the no is the no I'm giving.............

Edited by Dili1234

Attachments 1.jpg 16.66 KB
2
Contributors
3
Replies
9
Views
4 Years
Discussion Span
Last Post by tinstaafl
1

Just on the surface, it looks like you're missing a ")", this might work,

Dim insert1 As SqlCommand = New SqlCommand("INSERT INTO [VBP].[dbo].[Return_Total] ([RGN0],[Date] ,[Totalamount],[User_Id],[C_NIC],[Comments],[Bill_No]) values ('" & Val(TextBox2.Text) & "','" & DateTimePicker1.Value.Date & "','" & TextBox4.Text & "','" & TextBox6.Text & "','" & TextBox3.Text & "','" & TextBox5.Text & "','" & Val(TextBox8.Text) & "'"), myConnection)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.