我想做一个登陆模块
Private Sub Button1_ServerClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ServerClick
Dim StrUser As String, StrPass As String
Dim BValid As Boolean
Dim ConVM As SqlConnection
Dim CmdCoInfo As SqlCommand
Dim DrCoInfo As Sqldatareader Dim StrSQL As String StrUser = Txtname.Text
StrPass = Txtpassword.Text
BValid = False
ConVM = New Sqlconnection("Server=KITTY;UID=sa;PWD=;Database=study")
StrSQL = "SELECT * FROM student WHERE id='" & StrUser & "'"
CmdCoInfo = New SqlCommand(StrSQL, ConVM)
ConVM.Open()
DrCoInfo = CmdCoInfo.ExecuteReader()
While DrCoInfo.Read()
If DrCoInfo("UserName") <> "" And DrCoInfo("Password") <> "" Then
Response.Cookies("ValidUser").Value = DrCoInfo("UserName")
Response.Cookies("ValidUser").Expires = DateTime.Now.AddMonths(1)
BValid = True
Else
End If
End While
ConVM.Close()
If BValid = True Then
Response.Redirect("index.aspx")
ElseIf BValid = False Then
Lb1message.Text = "Login Error: Please try again."
End If
我建立了sqldataadapter1 sqlconnection1 dataset1,用以上代码时,报错未定义类型SqlConnection
SqlCommand Sqldatareader
是为什么啊?该怎么改动啊?多谢各位大侠!
Private Sub Button1_ServerClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ServerClick
Dim StrUser As String, StrPass As String
Dim BValid As Boolean
Dim ConVM As SqlConnection
Dim CmdCoInfo As SqlCommand
Dim DrCoInfo As Sqldatareader Dim StrSQL As String StrUser = Txtname.Text
StrPass = Txtpassword.Text
BValid = False
ConVM = New Sqlconnection("Server=KITTY;UID=sa;PWD=;Database=study")
StrSQL = "SELECT * FROM student WHERE id='" & StrUser & "'"
CmdCoInfo = New SqlCommand(StrSQL, ConVM)
ConVM.Open()
DrCoInfo = CmdCoInfo.ExecuteReader()
While DrCoInfo.Read()
If DrCoInfo("UserName") <> "" And DrCoInfo("Password") <> "" Then
Response.Cookies("ValidUser").Value = DrCoInfo("UserName")
Response.Cookies("ValidUser").Expires = DateTime.Now.AddMonths(1)
BValid = True
Else
End If
End While
ConVM.Close()
If BValid = True Then
Response.Redirect("index.aspx")
ElseIf BValid = False Then
Lb1message.Text = "Login Error: Please try again."
End If
我建立了sqldataadapter1 sqlconnection1 dataset1,用以上代码时,报错未定义类型SqlConnection
SqlCommand Sqldatareader
是为什么啊?该怎么改动啊?多谢各位大侠!
解决方案 »
- 如何判定cookies是否过期。
- 请教高手,align=top为什么不起作用!
- 又见asp.net页面传值问题!!烦
- textbox控件设置了autopostback属性后如何控制鼠标的焦点?
- ----求一简单功能的实现思路??————-
- 【微软专家,高手】如何保存在自定义控件(*.dll)中动态加载的用户控件(*.ascx)的视图状态(ViewState)
- ▲▲▲挥泪求解:如何根据xml文件的结构,在aspx页面进行显示?高手们快来吧!
- 如何将密码框内容转换为一般文字
- 建立javascript 文件的问题?
- 关于Handles MyBase.Load的问题
- 一个简单的参数传递问题
- 在线考试系统(毕业设计)的困惑!~给点意见,急!~~~~~~~~~~~~~~~~~
using System.Data.SqlClient;写在哪里啊?
VB.NET:
imports System.data
imports system.data.sqlclientc#:
using System.Data;
using System.Data.SqlClient;都在NameSpace的前面,也就是文档的最前面(最上面)
using System;
using System.IO;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace netpix
{
/// <summary>
/// index 的摘要说明。
/// </summary>
public class index : System.Web.UI.Page
{
}