I have a problem during insert data in my database (sql server 2000) in vb.net2008.
i use sqlhelper in my project.i put this lines in insertbutton click event:
'reg_no
Dim reg_no As string
reg_no = TextBox1.Text
'book_name
Dim book_name As String
book_name = TextBox2.Text
'type
Dim type As String
type = TextBox3.Text
'writer
Dim writer As String
writer = TextBox4.Text
Dim insstr = "insert into book_table (reg_no,book_name,writer,type) values ( " + reg_no + "," + book_name + "," + writer + "," + type + ")"
Dim ds As New DataSet
ds = SqlHelper.ExecuteDataset(cnstr, CommandType.Text, insstr)
my conection string is:
Public cnstr As String = "data source=ali; Initial Catalog=library ; integrated security=True"
BUT WHEN PROGRAM RUN AND I WANT TO INSERT THE DATA BY CLICKING INSERTBUTTON,A POPUP SHOW THAT :
******************************
SqlException was unhandled
The name 'bookname' is not permitted in this context (point to ----> da.Fill(ds) in sqlhelper.vb). Only constants, expressions, or variables allowed here. Column names are not permitted.
******************************
whats my problem?؟?؟?؟?؟?؟?؟?
what you think?
do you offer to use sqlhelper for this case?
i use sqlhelper in my project.i put this lines in insertbutton click event:
'reg_no
Dim reg_no As string
reg_no = TextBox1.Text
'book_name
Dim book_name As String
book_name = TextBox2.Text
'type
Dim type As String
type = TextBox3.Text
'writer
Dim writer As String
writer = TextBox4.Text
Dim insstr = "insert into book_table (reg_no,book_name,writer,type) values ( " + reg_no + "," + book_name + "," + writer + "," + type + ")"
Dim ds As New DataSet
ds = SqlHelper.ExecuteDataset(cnstr, CommandType.Text, insstr)
my conection string is:
Public cnstr As String = "data source=ali; Initial Catalog=library ; integrated security=True"
BUT WHEN PROGRAM RUN AND I WANT TO INSERT THE DATA BY CLICKING INSERTBUTTON,A POPUP SHOW THAT :
******************************
SqlException was unhandled
The name 'bookname' is not permitted in this context (point to ----> da.Fill(ds) in sqlhelper.vb). Only constants, expressions, or variables allowed here. Column names are not permitted.
******************************
whats my problem?؟?؟?؟?؟?؟?؟?
what you think?
do you offer to use sqlhelper for this case?