|
At the top of the Default.aspx.vb page, you also have to quote this code Imports System.Data.SqlClient
Then code in the database to give a simple example.
Dim con As New SqlConnection ("server = .; database = jie; uid = sa; pwd =;")
// server =. represents the local database connected, database writes the database name you want to connect, user name and password to write your own.
Dim cmd As New SqlCommand ("select Uid from user table where user name = '"&TextBox1.Text&"' and user password = '"&TextBox2.Text&"'", con)
Dim dr As SqlDataReader
con.Open ()
dr = cmd.ExecuteReader
If dr.Read Then
Response.Redirect ("WebForm1.aspx")
Else
Response.Write ("<script> alert ('The username or password is wrong') </ script>")
End If
dr.Close ()
con.Close () |
|