So my group and i have been working on a ASP.net website for a tech prep showcase. We currently have connected the MS Sql Database that comes with Visual Web Developer. We are currently having a problem gathering data from the SQL Database and seeing if it is equivalent to the users input. We have attempted this for last 3 days and still have difficulty with it. We are using VB for the back side programing.
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.Configuration
Protected Sub Login1_Authenticate(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) _
Handles Login1.Authenticate
Dim username As String
Dim pwd As String
Dim pName As String
username = Login1.UserName
pwd = Login1.Password
pName = ""
Dim conn1 As New SqlConnection()
conn1.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
conn1.Open()
Dim sqlUserName As String
sqlUserName = "Select UserName, password FROM LogIn"
sqlUserName &= " WHERE (UserName = @UserName"
sqlUserName &= " AND password = @Password)"
Dim com As New SqlCommand(sqlUserName, conn1)
com.Parameters.AddWithValue("@UserName", username)
com.Parameters.AddWithValue("@Password", pwd)
If username = sqlUserName Then
Response.Redirect("index.asp")
End If
conn1.Close()
End Sub