"未将对象引用设置到对象的实例"的问题
我把代码帖出来了,大家看一下,哪儿错了`~~错误提示出现在sub update_click(sender as object,e as eventargs)这个模块的strsql这条语句上~
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
If Not IsPostBack Then
Call mydatabind()
End If
End Sub
Sub mydatabind()
Dim conn As New SqlConnection("server=(local);database=xf;uid=sa;pwd=997mb;")
Dim newid As String = Request.QueryString("nid")
Dim strsql As String
strsql = "select * from news where nid='" & newid & "'"
Dim cmd As New SqlCommand(strsql, conn)
Dim adp As New SqlDataAdapter(cmd)
Dim ds As New DataSet
adp.Fill(ds, "news")
DataList1.DataSource = ds
DataList1.DataBind()
End Sub
Sub update_click(ByVal sender As Object, ByVal e As EventArgs)
Dim conn As New SqlConnection("server=(local);database=xf;uid=sa;pwd=997mb;")
Dim strsql As String
strsql = "update news set nid='" & textbox1.Text & "',ntitle='" & textbox2.Text & "',ndetail='" & textbox3.Text & "',ntime='" & textbox4.Text & "'"
Dim cmd As New SqlCommand(strsql, conn)
conn.Open()
cmd.ExecuteNonQuery()
conn.Close()
label1.Text = "修改成功!"
Call mydatabind()
End Sub