Slightly updated code after a morning of reading -
-----------------------------------------
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 = tbxEmail
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 = tbxModel
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)
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
objEmail.To = ConfigurationSettings.AppSettings("MailToAddress")
objEmail.From =
ConfigurationSettings.AppSettings("MailFromAddress")
objEmail.Subject = userID
objEmail.Body = "Logged in: " & DateTime.Now().ToString()
objEmail.SmtpServer = "sendmail.myhost.com'
End With
System.Web.Mail.SmtpMail.Send(objMsg)
end sub
-------------------------------------------------------
Jeff
----- Original Message -----
From: Jeff Gramins
To: [email protected]
Sent: Thursday, November 10, 2005 8:39 AM
Subject: Re: [AspNetAnyQuestionIsOk] Re: Send Mail on Page Load
The Email subject is supposed to contain the CustomerID, which comes from the
database (I use email and the model they want as username and password on the
login).
Right now with the code I posted I get a compilation error that says "DataRow
is not defined" and "Dim dr as DataRow = GetUserByName(username)" is
highlighted. I'm sure once that error is cleared, there will be more to follow.
Jeff
[Non-text portions of this message have been removed]
------------------------ Yahoo! Groups Sponsor --------------------~-->
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/T8sf5C/tzNLAA/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/