| | |
email password from sql database
Please support our ASP.NET advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Sep 2008
Posts: 351
Reputation:
Solved Threads: 30
I can't figure out how to email the password from a sql database I have a formview on my webpage can I pull it from there? or can I pull it directly on my backend code? Using C# I tried + passwordlabel + I tried using findcontrol.formview I can seem to get it right
The part where I have label2.text = findcontrol... I get this in the email System.Web.UI.WebControls.Label
my email.aspx code
The part where I have label2.text = findcontrol... I get this in the email System.Web.UI.WebControls.Label
my email.aspx code
ASP.NET Syntax (Toggle Plain Text)
using System; using System.Data; using System.Configuration; using System.Collections; using System.Net.Mail; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Web.Configuration; using System.Net; using System.Text; using System.IO; using System.Data.SqlClient; public partial class Forgot : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void bc_fpwd_submit_button_Click(object sender, EventArgs e) { { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString.ToString()); con.Open(); SqlCommand sqlCMD = con.CreateCommand(); sqlCMD.CommandText = "SELECT * FROM users WHERE email = @email"; // (this should really be a stored procedure, shown here for simplicity) // Fill our parameters sqlCMD.Parameters.Add("@email", SqlDbType.VarChar, 50).Value = bc_fpwd_uid_textbox.Text; SqlDataAdapter sqlAD = new SqlDataAdapter(sqlCMD); DataSet dsDataSet = new DataSet(); sqlAD.Fill(dsDataSet); if (dsDataSet.Tables[0].Rows.Count > 0) { Form.Visible = false; FoundPW.Visible = true; Label1.Text = bc_fpwd_uid_textbox.Text; bc_fuid_validator.Visible = true; Label2.Text = this.FormView1.FindControl("passwordLabel").ToString(); string MyValue = Label2.Text; // Do this if username not found in database } else { Form.Visible = true; FoundPW.Visible = false; bc_no_uid_label.Visible = true; } con.Close(); sqlAD.Dispose(); } } protected void bc_fpwd_cancel_button_Click(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { if (Page.IsValid) { System.Configuration.Configuration config = WebConfigurationManager.OpenWebConfiguration(base.Request.ApplicationPath); AppSettingsSection appSettings = (AppSettingsSection)config.GetSection("appSettings"); //appSettings.Settings["EmailHost"].Value string emailHost = appSettings.Settings["EmailHost"].Value; string fromAddress = appSettings.Settings["FromEmailAddr"].Value; string toAddress = "me@vortexamerica.com"; SmtpClient smtpClient = new SmtpClient(emailHost); // Default in IIS will be localhost //smtpClient.Host = "localhost"; //Default port will be 25 smtpClient.Port = 25; MailMessage message = new MailMessage(); message.IsBodyHtml = false; message.Priority = MailPriority.High; message.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure; try { message.Subject = "Paal Camera Forgot Password"; message.Body += "Sender: " + bc_fpwd_uid_textbox.Text + "\n"; message.Body += "Password: " + FormView1.FindControl("passwordlabel").ToString()+ "\n"; smtpClient.Send(fromAddress, toAddress, message.Subject, message.Body); } catch (Exception ex) { // Display error panel // Log error } } } }
Last edited by freshfitz; Feb 7th, 2009 at 5:10 pm.
•
•
Join Date: Sep 2008
Posts: 351
Reputation:
Solved Threads: 30
I ended up getting it I had to use this
•
•
•
•
using web = System.Web.UI.WebControls;
web.Label password = (web.Label)FormView1.FindControl("passwordlabel");
string mypassword = password.Text;
//Label2.Text = this.FormView1.FindControl("passwordLabel").ToString();
Label2.Text = password.Text;
![]() |
Similar Threads
- search database using php (PHP)
- Reading data from SQL (Visual Basic 4 / 5 / 6)
- email (PHP)
- My Sql Reports (MySQL)
- Insert into sql database (ASP.NET)
- Registration and Login scripts using VB and Oledbconnection to Access Database (ASP.NET)
- Unable to insert data into SQL Database (ASP)
Other Threads in the ASP.NET Forum
- Previous Thread: WHERE clause in vwd 2005 express
- Next Thread: asp.net with flash page speed optimization
Views: 953 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 3.5 ajax appliances application asp asp.net beginner box browser businesslogiclayer button c# c#gridviewcolumn cac checkbox child class compatible complex confirmationcodegeneration content contenttype control countryselector courier database datagrid datagridview datalist deployment development dgv dialog dropdown dropdownmenu dynamic edit embeddingactivexcontrol feedback fileuploader fill findcontrol flash flv folder form forms gridview gudi homeedition hosting identity iis image index javascript jquery languages list maps menu mobile mssql nameisnotdeclared novell order problem profile ratings redirect refer relationaldatabases response.redirect search security select serializesmo.table sessionvariables silverlight software sql ssl tracking treeview typeof validatedate validation vb vb.net vista visual-studio visualstudio vs2008 web webarchitecture webdevelopment wizard xml






