EDN Admin
Well-known member
<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 <img alt="" src="http://social.msdn.microsoft.com/Forums/getfile/289484 <img alt="" src="http://social.msdn.microsoft.com/Forums/getfile/289483
View the full article
Предметы, Ученики и Экзамены <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 <img alt="" src="http://social.msdn.microsoft.com/Forums/getfile/289484 <img alt="" src="http://social.msdn.microsoft.com/Forums/getfile/289483
View the full article