日期:2014-05-18 浏览次数:20475 次
username = txtname.Text.Trim() userpassword = txtpass.Text.Trim() comdstr ="select * from users where (username='" & username & "') and (userpassword='" & userpassword & "')" comd = New SqlClient.SqlCommand(comdstr, objconn) objconn.open() Dim dr As SqlClient.SqlDataReader dr = comd.ExecuteReader(CommandBehavior.CloseConnection) If Not dr.read() Then Response.Write( " <script language= 'jacascript '> alert( '输入的用户名或密码错误 ');history.go(-1); </script> ") Else Response.Redirect( "host.aspx ") End If
------解决方案--------------------
打错了,更正一下:
至于 "“read”不是“System.Data.SqlClient.SqlDataAdapter”的成员 ",从.net问世以来,SqlDataReader类一直就有一个Read()方法,我都用过N遍了,直到.net2008都有,VB不区分大小写,所以写read也没错.
你把我的代码放进去,我明明定义了Dim dr As SqlClient.SqlDataReader,你是不是又改成了SqlDataAdapter?