呵呵,谢谢你哦,找的好辛苦哦。
做的真好,非常感谢!
偶要减肥!!!
谢谢 给我的数据库
我作了一个和你的功能查不多的程序,但出了很多错误,修改记录时,无出现错误,但数据库里的记录不变,代码如下:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim conn As New SqlConnection
conn.ConnectionString = ConfigurationSettings.AppSettings("aa")
conn.Open()
Dim cmd As New SqlCommand
cmd.Connection = conn
cmd.CommandText = "update info set u_name='" & TextBox1.Text & "',u_sex='" & TextBox2.Text & "',u_birt='" & TextBox3.Text & "',u_indate='" & TextBox4.Text & "',u_code='" & TextBox5.Text & "',u_tel='" & TextBox6.Text & "',u_zhy='" & TextBox7.Text & "',u_dw='" & TextBox8.Text & "',u_time1='" & TextBox9.Text & "',u_sch1='" & TextBox10.Text & "',u_zhy1='" & TextBox11.Text & "',u_time2='" & TextBox12.Text & "',u_sch2='" & TextBox13.Text & "',u_zhy2='" & TextBox14.Text & "',u_time3='" & TextBox15.Text & "',u_sch3='" & TextBox16.Text & "',u_zhy3='" & TextBox17.Text & "',u_chg='" & TextBox18.Text & "',u_ky='" & TextBox19.Text & "',u_xsh='" & TextBox20.Text & "',u_xzhw1='" & TextBox21.Text & "',u_xdate1='" & TextBox22.Text & "',u_xmch1='" & TextBox23.Text & "',u_xzhw2='" & TextBox24.Text & "',u_xdate2='" & TextBox25.Text & "',u_xmch2='" & TextBox26.Text & "',u_xzhw3='" & TextBox27.Text & "',u_xdate3='" & TextBox28.Text & "',u_xmch3='" & TextBox29.Text & "',u_shzhw1='" & TextBox30.Text & "',u_shdate1='" & TextBox31.Text & "',u_shmch1='" & TextBox32.Text & "',u_shzhw2='" & TextBox33.Text & "',u_shdate2='" & TextBox34.Text & "',u_shmch2='" & TextBox35.Text & "',u_shzhw3='" & TextBox36.Text & "',u_shdate3='" & TextBox37.Text & "',u_shmch3='" & TextBox38.Text & "',u_men='" & TextBox39.Text & "' where u_id='" & TextBox40.Text & "'"
cmd.ExecuteNonQuery()
conn.Close()
End Sub
我做了一个和你功能查不多的程序,但修改记录时,运行时页面没有什么错误,但数据库里的记录就不变这是怎么回事啊,代码如下:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim conn As New SqlConnection
conn.ConnectionString = ConfigurationSettings.AppSettings("aa")
conn.Open()
Dim cmd As New SqlCommand
cmd.Connection = conn
cmd.CommandText = "update info set u_name='" & TextBox1.Text & "',u_sex='" & TextBox2.Text & "',u_birt='" & TextBox3.Text & "',u_indate='" & TextBox4.Text & "',u_code='" & TextBox5.Text & "',u_tel='" & TextBox6.Text & "',u_zhy='" & TextBox7.Text & "',u_dw='" & TextBox8.Text & "',u_time1='" & TextBox9.Text & "',u_sch1='" & TextBox10.Text & "',u_zhy1='" & TextBox11.Text & "',u_time2='" & TextBox12.Text & "',u_sch2='" & TextBox13.Text & "',u_zhy2='" & TextBox14.Text & "',u_time3='" & TextBox15.Text & "',u_sch3='" & TextBox16.Text & "',u_zhy3='" & TextBox17.Text & "',u_chg='" & TextBox18.Text & "',u_ky='" & TextBox19.Text & "',u_xsh='" & TextBox20.Text & "',u_xzhw1='" & TextBox21.Text & "',u_xdate1='" & TextBox22.Text & "',u_xmch1='" & TextBox23.Text & "',u_xzhw2='" & TextBox24.Text & "',u_xdate2='" & TextBox25.Text & "',u_xmch2='" & TextBox26.Text & "',u_xzhw3='" & TextBox27.Text & "',u_xdate3='" & TextBox28.Text & "',u_xmch3='" & TextBox29.Text & "',u_shzhw1='" & TextBox30.Text & "',u_shdate1='" & TextBox31.Text & "',u_shmch1='" & TextBox32.Text & "',u_shzhw2='" & TextBox33.Text & "',u_shdate2='" & TextBox34.Text & "',u_shmch2='" & TextBox35.Text & "',u_shzhw3='" & TextBox36.Text & "',u_shdate3='" & TextBox37.Text & "',u_shmch3='" & TextBox38.Text & "',u_men='" & TextBox39.Text & "' where u_id='" & TextBox40.Text & "'"
cmd.ExecuteNonQuery()
conn.Close()
End Sub
Dim conn As New SqlConnection
conn.ConnectionString = ConfigurationSettings.AppSettings("aa")
Dim cmd As New SqlCommand
cmd.CommandText = "select u_id as 编号,u_name as 姓名,u_sex as 性别,u_indate as 入学时间,u_zhy as 所学专业,u_dw as 所在单位 from info where u_id='" & TextBox1.Text & "'"
cmd.Connection = conn
conn.Open()
Dim dr As New SqlDataAdapter
Dim ds As New DataSet
dr.Fill(ds, "info")
DataGrid1.DataSource = ds.Tables("info")
DataGrid1.DataBind()
conn.Close()
出现错误如下:
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。
源错误:
行 42:
行 43: cmd.CommandText = "select u_id as 编号,u_name as 姓名,u_sex as 性别,u_indate as 入学时间,u_zhy as 所学专业,u_dw as 所在单位 from info where u_id='" & TextBox1.Text & "'"
行 44: cmd.Connection = conn
行 45: conn.Open()
行 46: Dim dr As New SqlDataAdapter
源文件: c:\inetpub\wwwroot\dn\cbh.aspx.vb 行: 44
堆栈跟踪:
[NullReferenceException: 未将对象引用设置到对象的实例。]
dn.chaxun.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\dn\cbh.aspx.vb:44
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()
Dim conn As New SqlConnection
conn.ConnectionString = ConfigurationSettings.AppSettings("aa")
Dim cmd As New SqlCommand
cmd.CommandText = "select u_id as 编号,u_name as 姓名,u_sex as 性别,u_indate as 入学时间,u_zhy as 所学专业,u_dw as 所在单位 from info where u_id='" & TextBox1.Text & "'"
cmd.Connection = conn
conn.Open()
Dim dr As New SqlDataAdapter
Dim ds As New DataSet
dr.Fill(ds, "info")
DataGrid1.DataSource = ds.Tables("info")
DataGrid1.DataBind()
conn.Close()
出现错误如下:
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。
源错误:
行 42:
行 43: cmd.CommandText = "select u_id as 编号,u_name as 姓名,u_sex as 性别,u_indate as 入学时间,u_zhy as 所学专业,u_dw as 所在单位 from info where u_id='" & TextBox1.Text & "'"
行 44: cmd.Connection = conn
行 45: conn.Open()
行 46: Dim dr As New SqlDataAdapter
源文件: c:\inetpub\wwwroot\dn\cbh.aspx.vb 行: 44
堆栈跟踪:
[NullReferenceException: 未将对象引用设置到对象的实例。]
dn.chaxun.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\dn\cbh.aspx.vb:44
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()
试试将程序代码改为下面的:
Dim dr As New SqlDataAdapter
Dim ds As New DataSet
conn.Open()
cmd.CommandText = "select u_id as 编号,u_name as 姓名,u_sex as 性别,u_indate as 入学时间,u_zhy as 所学专业,u_dw as 所在单位 from info where u_id='" & TextBox1.Text & "'"
cmd.Connection = conn
cmd.CommandType = CommandType.Text
dr.SelectCommand = comm
dr.Fill(ds, "info")
DataGrid1.DataSource = ds.Tables("info")
DataGrid1.DataBind()
conn.Close()