TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Shourya Verdhan
NA
88
56.2k
How to insert values in table when table name comes from textboxid using window form
Nov 3 2012 9:26 PM
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]
Reply
Answers (
1
)
Use of Exception Handling in SQL Server.
can unique key column accept multiple null value