62,254
社区成员
发帖
与我相关
我的任务
分享
cmd = New OleDbCommand(String.Format("select * from tbl_member where m_user='{0}' and m_code='{1}' ", tb_user.Text.Trim(), tb_code.Text.Trim()), c.pconn)
Dim num As Integer
num = cmd.ExecuteScalar()
If num Then
Session("login") = tb_user.Text
Else
MsgBox("Error")
End If
Imports System.Data
Imports System.Data.SqlClient
Partial Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim dr As SqlDataReader = Nothing
Dim cmd As SqlCommand = Nothing
Dim conn As SqlConnection = New SqlConnection("你的连接字符串")
Dim SqlStatement As String = String.Format( _
"select * from tbl_member where m_user='{0}' and m_code='{1}' " _
, tb_user.Text.Trim.Replace("'", "''"), tb_code.Text.Trim.Replace("'", "''") _
)
Using (conn)
If conn.State = ConnectionState.Closed Then conn.Open()
cmd = New SqlCommand(SqlStatement, conn)
dr = cmd.ExecuteReader
If dr.Read Then
Session("login") = tb_user.Text
Else
'MsgBox("Error") <-- WebForm是不能使用这个的
Response.Write("<script type='text/javascript'>alert('没有该用户');</script>")
End If
End Using
End Sub
End Class