帮我看看我写的错在那里了,我用这个程序后添到成绩里的值没有写到库里,请各位哥哥一定要帮忙,小妹谢过了!! Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim myconn As New SqlConnection("Server = localhost; uid=sa;pwd=lcdgn;database=pygl") Dim ds As New DataSet() Dim sqld As SqlDataAdapter Dim str As String Dim obj As TextBox Dim dtable As DataTable Dim drows As DataRowCollection Dim drow As DataRow str = "select pyjh.xuehao,xsda.xingming,pyjh.kcxz,pyjh.khfs,pyjh.chengji from pyjh,xsda,kc where pyjh.xuehao=xsda.xuehao and kc.kcbh=pyjh.kcbh and kc.kcmc='" + TextBoxkcmc.Text + "' and pyjh.kksj='" + TextBoxkksj.Text + "'" myconn.Open() sqld = New SqlDataAdapter(str, myconn) Dim objc As New SqlCommandBuilder(sqld) sqld.Fill(ds, "mytable") dtable = ds.Tables("mytable") drows = dtable.Rows Dim introw As Integer dtable.AcceptChanges() sqld.Update(ds, "mytable") For introw = 0 To ds.Tables("mytable").Rows.Count - 1 drow = drows(introw) obj = DataGrid1.Items(introw).Cells(4).FindControl("textboxchengji") drow(4) = obj.Text Next myconn.Close() bind() End Sub
{ for(int i=0;i<DataGrid1.Items.Count;i++)
{
TextBox tb=(TextBox)DataGrid1.Items[i].Cells[4].FindControl("textboxchengji");
Label lb=(Label)DataGrid1.Items[i].Cells[4].FindControl("labelxuehao"); string sql="UPDATE "+tab+" SET chengji='"+tb.Text+"' WHERE xuehao= "+lb.Text;
DbExec(sql);
}
}
public bool DbExec(string sql)
{
DbOpen();
try
{
infocomm=new OleDbCommand(sql,linkDb);
infocomm.ExecuteNonQuery();
infocomm.Dispose();
linkDb.Close();
return true;
}
catch(OleDbException e)
{
linkDb.Close();
getErr+="["+e.ErrorCode.ToString()+"]"+e.Message.ToString();
return false;
}
}
Label lb=(Label)DataGrid1.Items[i].Cells[0].FindControl("labelxuehao");
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim myconn As New SqlConnection("Server = localhost; uid=sa;pwd=lcdgn;database=pygl")
Dim ds As New DataSet()
Dim sqld As SqlDataAdapter
Dim str As String
Dim obj As TextBox
Dim dtable As DataTable
Dim drows As DataRowCollection
Dim drow As DataRow
str = "select pyjh.xuehao,xsda.xingming,pyjh.kcxz,pyjh.khfs,pyjh.chengji from pyjh,xsda,kc where pyjh.xuehao=xsda.xuehao and kc.kcbh=pyjh.kcbh and kc.kcmc='" + TextBoxkcmc.Text + "' and pyjh.kksj='" + TextBoxkksj.Text + "'"
myconn.Open()
sqld = New SqlDataAdapter(str, myconn)
Dim objc As New SqlCommandBuilder(sqld)
sqld.Fill(ds, "mytable")
dtable = ds.Tables("mytable")
drows = dtable.Rows
Dim introw As Integer
dtable.AcceptChanges()
sqld.Update(ds, "mytable")
For introw = 0 To ds.Tables("mytable").Rows.Count - 1
drow = drows(introw)
obj = DataGrid1.Items(introw).Cells(4).FindControl("textboxchengji")
drow(4) = obj.Text
Next
myconn.Close()
bind()
End Sub