主题:请教高手一个用vb语言编写数据库程序编译出错的问题
我是一个ASP.net初学者,一个很普通的数据库连接,用户在此页面输入正确的用户名和口令即可登陆系统
代码:Sub LoginBtn_Click(sender as object, e as eventargs)
dim Cnn as oledbconnection
dim cmd as oledbcommand
dim dataR as oledbdatareader
if page.isvalid then
Cnn=new oledbconnection(configurationsettings.appsettings("connection"))
cmd=new oledbcommand("select * from passin where user_id='"&text_username.text&"' and password='"&text_userpass.text&"'",Cnn)
Cnn.open()
datar=cmd.executereader()
if datar.read() then
session("CurrUser")=datar("code").tostring()
session("DispUser")=datar("userdispname").tostring()
session("LoginTime")=now()
response.redirect ("2.aspx")
Else
Label1.Text = "对不起,名称或口令错误!"
End If
End If
End Sub
出错信息:
编译器错误信息: BC30455: 没有为“Public Sub New(cmdText As String, connection As System.Data.OleDb.OleDbConnection, transaction As System.Data.OleDb.OleDbTransaction)”的参数“connection”指定参数。
[color=FF0000]行 11: cmd=new oledbcommand("select * from passin where user_id='"&text_username.text&"' and password='"&text_userpass.text&"'",Cnn)[/color]
代码:Sub LoginBtn_Click(sender as object, e as eventargs)
dim Cnn as oledbconnection
dim cmd as oledbcommand
dim dataR as oledbdatareader
if page.isvalid then
Cnn=new oledbconnection(configurationsettings.appsettings("connection"))
cmd=new oledbcommand("select * from passin where user_id='"&text_username.text&"' and password='"&text_userpass.text&"'",Cnn)
Cnn.open()
datar=cmd.executereader()
if datar.read() then
session("CurrUser")=datar("code").tostring()
session("DispUser")=datar("userdispname").tostring()
session("LoginTime")=now()
response.redirect ("2.aspx")
Else
Label1.Text = "对不起,名称或口令错误!"
End If
End If
End Sub
出错信息:
编译器错误信息: BC30455: 没有为“Public Sub New(cmdText As String, connection As System.Data.OleDb.OleDbConnection, transaction As System.Data.OleDb.OleDbTransaction)”的参数“connection”指定参数。
[color=FF0000]行 11: cmd=new oledbcommand("select * from passin where user_id='"&text_username.text&"' and password='"&text_userpass.text&"'",Cnn)[/color]