Tech
Forums
Jobs
Books
Events
Videos
Conference
Annual Conference
Bcrypt
Ai Conference
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
1
Reply
How to insert values in table when table name comes from textboxid using window form
Ask a question
Ask a question
Upload Source Code:
Select only zip and rar file.
Shourya Verdhan
11y
1.1k
1
Reply
Dear Friends,
i have a code where i insert values in table and
table name comes from textbox id
Code is...
SqlConnection con = new SqlConnection();
con.ConnectionString = "data source=NDTS12; initial Catalog=ndts_tm247; integrated security=true;";
con.Open();
string sql = "INSERT INTO " + txtemployeeid.Text.Trim() + "values('" + txtname.Text + "','" + txtcont.Text + "','" + txtcont2.Text + "','" + txtaddress.Text + "','" + txtmail.Text + "','" + txtsaletype.Text + "','" + txtamount.Text + "','" + dateTimePicker1.Text + "','" + txtissue.Text + "','" + txtstatus.Text + "','" + txttechname.Text + "','" + txtos.Text + "','" + txttvid.Text + "','" + txttvpw + "','" + txtdiscription.Text + "' )"; sql += ")";
SqlCommand cmd = new SqlCommand(sql, con);
cmd.ExecuteNonQuery();
con.Close();
But this code Generate an exception new
"' )"; sql += ")";
any one can tell
AS SOON AS POSIBLE
me where is the problem in this code
my email id is
[email protected]
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
Use of Exception Handling in SQL Server.
can unique key column accept multiple null value