Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
If Trim(Session("userid")) = "" Or IsDBNull(Session("userid")) Then
Response.Redirect("loin.aspx")
End If
Try
Dim conn As SqlClient.SqlConnection = New SqlClient.SqlConnection("server=(local);database=lianxi;user id=sa;pwd=")
Dim ad As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter("select * from student1 where stuid='" & Trim(Session("userid")) & "'", conn)
Dim st As Data.DataSet = New Data.DataSet
ad.Fill(st, "user")
Label1.Text = st.Tables("user").Rows(0).Item("stuID")
Label2.Text = st.Tables("user").Rows(0).Item("name")
Label3.Text = st.Tables("user").Rows(0).Item("sex")
Label4.Text = st.Tables("user").Rows(0).Item("birthday")
TextBox1.Text = st.Tables("user").Rows(0).Item("adrr")
TextBox2.Text = st.Tables("user").Rows(0).Item("phon")
Catch exc As Exception
Response.Redirect("loin.aspx")
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim conn As SqlClient.SqlConnection = New SqlClient.SqlConnection("server=(local);database=lianxi;user id=sa;pwd=")
Dim ad As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter("update student1 set adrr='" & Trim(textbox1.text)& "' where stuid='" & Trim(Session("userid")) & "'", conn)
Dim st As Data.DataSet = New Data.DataSet
End Sub
我想先把数据库的内容读出来...然后在改了textbox1.text的属性后写回数据库...但是写不回去...
[此贴子已经被作者于2006-11-5 9:41:07编辑过]