Dim conn As OleDbConnection
Dim str As String
conn = New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=" & Server.MapPath("test.mdb"))
str = "select count(*) from admin where adminname='" + TextBox1.Text + "'and adminpassword='" + TextBox2.Text + "'"
Dim cmd As New OleDbCommand(str, conn)
Try
conn.Open()
Dim count As String
count = cmd.ExecuteScalar
If count <> 0 Then
Dim str1 As String
str1 = "update admin set adminpassword='" + TextBox3.Text + " '"
Label1.Text = "密码修改成功"
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
Else
Label1.Text = "用户名或者原密码错误"
End If
conn.Close()
Catch ex As Exception
Response.Write(ex.Message)
End Try
结果是提示了修改成功!但是数据库里面就是没改!
还是不行
帮我看看是不是程序有问题啊!!!
Dim conn As OleDbConnection
Dim str As String
conn = New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=" & Server.MapPath("test.mdb"))
str = "select * from selecting where question like '%% TextBox1.Text %%'"
Dim dt As New DataTable
Dim cmd As New OleDbCommand(str, conn)
Dim da As New OleDbDataAdapter(cmd)
Try
conn.Open()
da.Fill(dt)
Dim count As String
count = cmd.ExecuteScalar
If count = 0 Then
Label2.Text = "对不起,没有符合条件的题目!"
Return
Else
DataGrid1.DataSource = dt
DataGrid1.DataBind()
End If
conn.Close()
Catch ex As Exception
Response.Write(ex.Message)
End Try