EDN Admin
Well-known member
<img alt="" src="http://social.msdn.microsoft.com/Forums/getfile/289489
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee Здравствуйте, на форме есть GridView, несколько textbox-ов и кнопка Insert . База в прикрепленном файле - состоит из 3-х таблиц
Предметы, Ученики и Экзамены <br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee Код C#<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee private void button1_Click(object sender, EventArgs e)<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee {<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee con = new SqlConnection("Data Source=(local);Initial Catalog=exam;Integrated Security=True"<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee con.Open();<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee str = "Insert into dbo.Exams(dbo.Exams.ID,dbo.Exams.Number,dbo.Exams.Date,dbo.Exams.Mark) <br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee Values (@id,@number,@date,@mark)";<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee com = new SqlCommand(str, con);<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee com.Parameters.AddWithValue("@id", subjectTextBox.Text);<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee com.Parameters.AddWithValue("@number", childrenTextBox.Text);<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee com.Parameters.AddWithValue("@date",DateTime.Now);<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee com.Parameters.AddWithValue("@mark", markTextBox.Text);<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee com.ExecuteNonQuery();<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee con.Close();<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee MessageBox.Show("Record Successfully Inserted"<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee }<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee не работает, где я ошибся? Нужно добавлять строки в GridView.
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee <img alt="" src="http://social.msdn.microsoft.com/Forums/getfile/289491
View the full article
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee Здравствуйте, на форме есть GridView, несколько textbox-ов и кнопка Insert . База в прикрепленном файле - состоит из 3-х таблиц
Предметы, Ученики и Экзамены <br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee Код C#<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee private void button1_Click(object sender, EventArgs e)<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee {<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee con = new SqlConnection("Data Source=(local);Initial Catalog=exam;Integrated Security=True"<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee con.Open();<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee str = "Insert into dbo.Exams(dbo.Exams.ID,dbo.Exams.Number,dbo.Exams.Date,dbo.Exams.Mark) <br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee Values (@id,@number,@date,@mark)";<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee com = new SqlCommand(str, con);<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee com.Parameters.AddWithValue("@id", subjectTextBox.Text);<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee com.Parameters.AddWithValue("@number", childrenTextBox.Text);<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee com.Parameters.AddWithValue("@date",DateTime.Now);<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee com.Parameters.AddWithValue("@mark", markTextBox.Text);<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee com.ExecuteNonQuery();<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee con.Close();<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee MessageBox.Show("Record Successfully Inserted"<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee }<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<br style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee не работает, где я ошибся? Нужно добавлять строки в GridView.
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee
<span style="color:#222222; font-family:Arial,Verdana; font-size:13px; line-height:normal; background-color:#eeeeee <img alt="" src="http://social.msdn.microsoft.com/Forums/getfile/289491
View the full article