注:
ftb为freetextbox控件
我增加新闻好用,修改时也提示成功,只是content字段内容不论怎么修改也没有改变,还是增加时的记录
content字段也就是freetextbox里读取到的内容
content字段在数据库中的类型是text,长度16
大家帮帮忙!!!
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
rqid = Request.QueryString("newsid")
If rqid <> "" Then
Button1.Visible = False
comdstr = "select newsid,bigclaname,title,newsfrom,newstime,writer,hit,newskey,content,newsis from news_article,news_bigclass where news_bigclass.bigclassid=news_article.bigclassid and newsid='" & rqid & "' order by newstime desc"
objcomd = New SqlCommand(comdstr, objconn)
objconn.Open()
newsdr = objcomd.ExecuteReader
If newsdr.Read() Then
title.Value = newsdr("title").ToString
newskey.Value = newsdr("newskey").ToString
newsfrom.Value = newsdr("newsfrom").ToString
writer.Value = newsdr("writer").ToString
ftb.Text = newsdr("content").ToString
Dim newis As Boolean
newis = newsdr("newsis")
If newis = True Then
newsis.Checked = True
Else
newsis1.Checked = True
End If
End If
objconn.Close()
Else
Button2.Visible = False
End If
comdstr = "select * from news_bigclass"
comd = New SqlCommand(comdstr, objconn)
objconn.Open()
adp = New SqlDataAdapter
adp.SelectCommand = comd
ds = New DataSet
adp.Fill(ds, "leibie")
bigclass.DataSource = ds.Tables("leibie")
bigclass.DataBind()
comd.Connection.Close()
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click ‘增加
Dim newsinsert, txt, txt1 As String
If Request.Form("newsis") = 1 Then
newis = 1
End If
If Request.Form("newsis") = 0 Then
newis = 0
End If
txt = ftb.Text
txt1 = Request.Form("newstime")
'txt1 = Year(Request.Form("newstime")) & "-" & Month(Request.Form("newstime")) & "-" & Day(Request.Form("newstime"))
newsinsert = "insert into news_article(bigclassid,title,writer,newskey,newstime,content,newsis,newsfrom) values('" & Request.Form("bigclass") & "','" & Request.Form("title").Trim() & "','" & Request.Form("writer").Trim() & "','" & Request.Form("newskey").Trim() & "','" & txt1 & "','" & txt & "','" & newis & "','" & Request.Form("newsfrom").Trim() & "')"
comd = New SqlCommand(newsinsert, objconn)
comd.Connection.Open()
comd.ExecuteNonQuery()
comd.Connection.Close()
Response.Write("<script language='javascript'>{window.alert('添加新闻成功');window.history.go(-1);}</script>")
End Sub
Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click ’修改
Dim newupdate, txt2, txt1 As String
rqid = Request.QueryString("newsid")
If Request.Form("newsis") = 1 Then
newis = 1
End If
If Request.Form("newsis") = 0 Then
newis = 0
End If
txt2 = ftb.Text
txt1 = Request.Form("newstime")
'txt1 = Year(Request.Form("newstime")) & "-" & Month(Request.Form("newstime")) & "-" & Day(Request.Form("newstime"))
newupdate = "update news_article set title='" & Request.Form("title").Trim() & "',writer='" & Request.Form("writer").Trim() & "',bigclassid='" & Request.Form("bigclass").Trim() & "',newskey='" & Request.Form("newskey").Trim() & "',newsfrom='" & Request.Form("newsfrom").Trim() & "',newsis='" & newis & "',newstime='" & txt1 & "',content='" & txt2 & "' where newsid='" & rqid & "'"
comd = New SqlCommand(newupdate, objconn)
comd.Connection.Open()
comd.ExecuteNonQuery()
comd.Connection.Close()
Response.Write("<script language='javascript'>{window.alert('成功修改新闻信息!');window.history.go(-1);}</script>")
'Response.Redirect("webform2.aspx?text=" & ftb.Text & "")
End Sub
End Class
[此贴子已经被作者于2006-11-29 10:37:56编辑过]