Reputation: 13
i just want to save details, but the code of function is giving error pls help. the code i have is:-
Dim con As New SqlConnection(Dal.conMain)
Dim x As String = ""
Try
Dim str As String = "insert into company_master(unqid, jurisdiction, company_name, tag_line, Address_Line1, Address_Line2, Pan_No, STR_No)"
Dim cmd As New SqlCommand(str, con)
cmd.CommandType = CommandType.Text
cmd.Parameters.AddWithValue("@jurisdiction", _jurisdiction)
cmd.Parameters.AddWithValue("@company_name", _company_name)
cmd.Parameters.AddWithValue("@tag_Line", _tag_Line)
cmd.Parameters.AddWithValue("@Address_Line1", _Address_Line1)
cmd.Parameters.AddWithValue("@Address_Line2", _Address_Line2)
cmd.Parameters.AddWithValue("@Pan_No", _Pan_No)
cmd.Parameters.AddWithValue("@str_No", _str_No)
con.Open()
x = cmd.ExecuteNonQuery().ToString()
con.Close()
If x = "" Or x = "0" Then
Return False
Else
Return True
End If
Upvotes: 0
Views: 74
Reputation: 3480
The problem you have is that your SQL is incomplete. SQL insert statements should be
insert into <tablename> (col1, col2) values (@col1, @col2);
you only have the first part of that in your code, ie:
insert into <tablename> (col1, col2);
add in the placeholder for the parameters and you should be fine.
Upvotes: 4