| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 373 人关注过本帖
标题:[求助]数据更新更新不了
只看楼主 加入收藏
fghydx
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2006-11-5
收藏
 问题点数:0 回复次数:4 
[求助]数据更新更新不了

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 ,并且也在页面的TextBox1.Text 上修改,可就是修改不了,也没有错误提示

搜索更多相关主题的帖子: 数据 
2006-11-05 10:24
小海龟
Rank: 6Rank: 6
等 级:贵宾
威 望:23
帖 子:1068
专家分:4
注 册:2006-8-1
收藏
得分:0 

你button1_click的代码都还没写全呢,怎么会更新?


[bc09] 犯强汉者,虽远比诛!
2006-11-05 10:34
fghydx
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2006-11-5
收藏
得分:0 
可以帮个忙写一下吗

2006-11-05 10:45
fghydx
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2006-11-5
收藏
得分:0 

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='这样就可以' where stuid='" & Trim(Session("userid")) & "'", conn)
Dim st As Data.DataSet = New Data.DataSet
ad.fill(st,"user")
End Sub
这样直接赋就可以...但把红色那部份换成addr='"&trim(textbox1.text)&"'就不行了


2006-11-05 11:10
fghydx
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2006-11-5
收藏
得分:0 

解决啦..但不知道原因.试出来的
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
ad.Fill(st, "user")
End Sub

Private Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.PreRender
'在此处放置初始化页的用户代码
Session("userid") = 200403010113
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")
TextBox1.Text = st.Tables("user").Rows(0)("adrr")
End Sub
End Class

放page_loade 里面就不行...


2006-11-05 11:58
快速回复:[求助]数据更新更新不了
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.041478 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved