SqlDataReader Reader = SqlCommand1..ExecuteReader()
if(Reader.Read()){
//执行你的代码
}
if(Reader.Read()){
//执行你的代码
}
解决方案 »
- 我的updatepanel控件 好像坏掉了
- File.AppendAllText()数据的时候偶尔会报字符串类型有问题
- Update set where 语句有错误,提醒字符串格式不正确
- asp.net数据控件 样式问题
- 我做开发半年了,但我现在什么也不会。怎么办?
- 参数传递问题
- 我数据录入时 是采用客户端控件文本框 input 好 还是服务器控件textbox好? 并且要验证输入的数据格式?
- 水晶报表控件的功能实现在B/S模式与C/S模式下是否一样(海波等专家请帮助)
- ASP.NET MVC4 局部刷新 (查看更多功能)
- aspx文件中如何将一个com引用进来?
- 为什么DataList中数据能帮定到ItemTemplate却不能绑定到HeaderTemplate
- 出现奇怪错误。请大家帮忙!!
SqlConnection Myconn=new SqlConnection(StringDatabase);
Myconn.Open();
string StrDB="select * from users where username='"+TextBox1.Text+"' and Password='"+TextBox2.Text+"'";
SqlCommand Mycomm=new SqlCommand(StrDB,Myconn);
SqlDataReader GetValue=null;
GetValue=Mycomm.ExecuteReader();
if(GetValue.Read())
{
GenSessionID GetID=new GenSessionID();
//调用构造函数获得id
string GetSessionID= GetID.sessionid;
Session["ID"]=GetSessionID;
Response.Redirect ("Menu.aspx");
}
GetValue.Close();
Myconn.Close ()
就会有SqlDataReader了
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickDim ZKcommunicate As New ZKCommunicate()
Dim strMember As String = ZKcommunicate.login(txtUserID.Text, txtPasswd.Text)
If strMember = "1" Then
Response.Redirect("Upload.aspx")
Else
Page.RegisterStartupScript("warnings", "<script>alert('用户名与密码不一致!');</script>") End If
end sub
Public Function login(ByVal UserID As String, ByVal Password As String) As String
Dim strsql As String
strsql = "select * from ZK_AP_Resume_User where User_Name='" & UserID & "' and User_Passwd='" & Password & "' "
objCommCommunciate = New SqlCommand(strsql, objConnCommunciate)
objConnCommunciate.Open()
Dim Reader As SqlDataReader = objCommCommunciate.ExecuteReader
Try
If Reader.Read Then
Return "1"
Else
Return "0"
End If
Finally
Reader.Close()
objConnCommunciate.Close() End Try End Function
dim da as sqlDataAdapter=new sqlDataAdapter("sql 语句",connection)
da.fill(ds,"tt")
if ds.tables("tt").rows.count>=0 then
response.write("您是合法用户")
else
response.write("您输入的帐户错误")
end if
ds.clear()
1.txtUserID.Text, txtPasswd.Text分别为用户名和密码输入框传出两个值给login过程,
2.过程login是在公共类里面写的
<%@ Import NameSpace="System.Data.SQLClient" %>
<%@ Import NameSpace="System.Data" %>
<%@ Page Language="vb" Debug="True" %>
如果没有你就加上,你的
Dim objReader As SqlDataReader
的语句就可以运行成功。
其它的判断方法你看上面的贴子吧,已经说的很详细了。PS:你也是用VB.net的啊?太好了,我也是的。呵呵
Debug="True"
是帮助你调试的,如果运行测试成功,发布的时候把这个代码给删除了
然后在Web.Config的里面加上Debug="False"
这样可以提高性能!