UGH!
I feel like a fool here. I have been trying to figure this out for most of the
day and can't get anywhere with it at all.
About the only thing I did right was the SQL (at least it tests as wanted). I
can do the login and redirect procedures, but not the sendMail procedure, at
least not with the database connection.
I am trying to set a login page to
1. Log a customer in using "Email" and "Model" columns in the database as
"Username" and "Passoword" functions, respectively.
2. Redirect them to "contentpage.aspx"
3. Send me an email when they log in
4. Pass data to "contentpage.aspx" so that dynamic fields on that page will
be filled with the proper info.
Within the login form I have 2 asp:TextBoxes: tbxEmail and tbxModel which
correspond to the Email and Model columns within the database.
I have tried a thousand variations of code but I am putting the one below that
I think it should be with code provided from here.
Help is GREATLY appreciated! I'm about to just make individual html pages for
each customer.
------------------------------------------------------
function Login(username, pwd) as Boolean
Dim Success as Boolean = False
Dim dr as DataRow = GetUserByName(username)
if not IsNothing(dr) then
Dim pwdDB as string = dr("Password")
if pwdDB = pwd then
Success = True
FormsAuthentication.SetAuthCookie(username, false)
SendMail(dr("UserID"), dr("Email"))
End if
End if
If Login(username, pwd) = true then
Response.Redirect("contentpage.aspx")
else
Msg.Text = "Invalid Credentials: Please try again"
End if
Return Success
End Function
Function dsCustomerLogin(ByVal email As String, ByVal model As String) As
System.Data.DataSet
Dim connectionString As String = "[MY CONNECTION STRING]"
Dim dbConnection As System.Data.IDbConnection = New
System.Data.SqlClient.SqlConnection(connectionString)
Dim queryString As String = "SELECT [tbl_onlinequotes].[CustomerID],
[tbl_onlinequotes].[Email], [tbl_onlinequotes].[Model] FROM [tbl_onlinequotes]
WHERE (([tbl_onlinequotes].[Email] = @Email) AND ([tbl_onlinequotes].[Model] =
@Model))"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_email As System.Data.IDataParameter = New
System.Data.SqlClient.SqlParameter
dbParam_email.ParameterName = "@Email"
dbParam_email.Value = email
dbParam_email.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_email)
Dim dbParam_model As System.Data.IDataParameter = New
System.Data.SqlClient.SqlParameter
dbParam_model.ParameterName = "@Model"
dbParam_model.Value = model
dbParam_model.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_model)
Dim dataAdapter As System.Data.IDbDataAdapter = New
System.Data.SqlClient.SqlDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)
Return dataSet
Dim conn As SqlConnection = New
SqlConnection(ConfigurationSettings.AppSettings("connString"))
Dim cmd As SqlCommand = New SqlCommand("GetUserByName", conn)
cmd.CommandType =CommandType.StoredProcedure
cmd.Parameters.Add("@Username", username)
Dim da As SqlDataAdapter = New SqlDataAdapter(cmd)
Dim dt As DataTable = New DataTable
da.Fill(dt)
Dim dr as DataRow
if dt.Rows.Count > 0 then
dr = dt.Rows(0) 'get the first row, should be the only row
End if
Return dr
End Function
private sub SendMail(userID as string, From as string)
Dim objMsg As New System.Web.Mail.MailMessage()
With objMsg
.To = ConfigurationSettings.AppSettings("MailToAddress")
.From = ConfigurationSettings.AppSettings("MailFromAddress")
.Subject = userID
.Body = "Logged in: " & DateTime.Now().ToString()
End With
System.Web.Mail.SmtpMail.Send(objMsg)
end sub
-------------------------------------------------------
Thanks!
Jeff
[Non-text portions of this message have been removed]
------------------------ Yahoo! Groups Sponsor --------------------~-->
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/saFolB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/