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
raajaa khan
NA
148
17.8k
insertion failed in database
Nov 3 2014 5:50 AM
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
Reply
Answers (
3
)
Getting an error when using http as Web location
Linq to Datatable