Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
3
Reply
insertion failed in database
raajaa khan
Nov 3 2014 5:50 AM
816
Reply
i am trying to insert into database, The problem is insertion data not save in my DataBase1.mdf i dont know why?
When my program is running, the first time that I insert data, they show in gridView1 but not store in database1.mdf
anyone help me
DB name : inventry
table name: addProduct
column : pid,title,descrtion,type,vendor,price,isbn
full project is attached
Button code file
private
void
button1_Click(
object
sender, EventArgs e) {
String
con = ConfigurationManager.ConnectionStrings[
"inven"
].ConnectionString; SqlConnection connection =
new
SqlConnection(con); connection.Open(); SqlCommand cmd =
new
SqlCommand(
"Insert into addProduct(title,descrtion,type,vendor,price,isbn) values(@title,@descrtion,@type,@vendor,@price,@isbn)"
, connection); cmd.Parameters.AddWithValue(
"@title"
, textBox1.Text); cmd.Parameters.AddWithValue(
"@descrtion"
, textBox2.Text); cmd.Parameters.AddWithValue(
"@type"
, textBox3.Text); cmd.Parameters.AddWithValue(
"@vendor"
, textBox4.Text); cmd.Parameters.AddWithValue(
"@price"
, textBox5.Text); cmd.Parameters.AddWithValue(
"@isbn"
, textBox6.Text);
int
rows = cmd.ExecuteNonQuery();
if
(rows !=
0
) { MessageBox.Show(
"Inserted"
); }
else
{ MessageBox.Show(
"Insertion failure"
); } connection.Close(); }
Attachment:
inventry_system.rar
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
3
)
Next Recommended Forum
Filter from Gridview
loop two variabels untill a specific count in c#.net