Hi All,
i am Developing School management Project in Asp.net and sql server.
Description:
When New User Registration on my site , the details will go Admin Approve Forms Will Data base, When Admin Approve the New student , the student Will get UserName And Password. this process working Perfectly in my Local System. The Same Code upload the Godady server the user not getten username and password let me know Any one iam Doing Wrong Any Ware. in the Below I just share the Source code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Net;
using System.Net.Mail;
using System.Security.Cryptography.X509Certificates;
using System.Net.Security;
using System.Text;
public partial class AdminAcceptstudents : System.Web.UI.Page
{
SqlConnection conn = new SqlConnection("Data Source=198.71.226.6;Initial Catalog=ritsindia_MuraliIIT;User ID=Rits;Password=rits@1234");
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
Bind_Data();
}
private void Bind_Data()
{
SqlConnection conn = new SqlConnection("Data Source=198.71.226.6;Initial Catalog=ritsindia_MuraliIIT;User ID=RITS;Password=rits@1234");
string s = "select * from NewStudentRegistrationForm ORDER BY Userid DESC; ";
//SqlCommand cmd = new SqlCommand("s, conn");
SqlDataAdapter da = new SqlDataAdapter(s, conn);
//cmd.CommandType = CommandType.Text;
DataSet ds = new DataSet();
da.Fill(ds, "NewStudentRegistrationForm");
GvApproveStudent.DataSource = ds.Tables[0];
GvApproveStudent.DataBind();
}
public void chkStatus_OnCheckedChanged(object sender, EventArgs e)
{
CheckBox chkStatus = (CheckBox)sender;
GridViewRow row = (GridViewRow)chkStatus.NamingContainer;
string UserId = row.Cells[7].Text;
bool ApproveStatus = chkStatus.Checked;
string constr = @"Data Source=198.71.226.6;Initial Catalog=ritsindia_MuraliIIT;User ID=RITS;Password=rits@1234";
string query = "UPDATE NewStudentRegistrationForm SET ApproveStatus = @ApproveStatus WHERE UserId = @UserId";
SqlConnection con = new SqlConnection(constr);
con.Open();
SqlCommand com = new SqlCommand(query, con);
com.CommandType = CommandType.Text;
com.Parameters.Add("@ApproveStatus", SqlDbType.Bit).Value = ApproveStatus;
com.Parameters.Add("@UserId", SqlDbType.Char).Value = UserId;
com.ExecuteNonQuery();
}
private static bool SendEmail(string fromEmail, string toEmail, string subject, string content, string userName, string password, string smtpServer, int portNumber)
{
bool isSent = false;
try
{
MailMessage msg = new MailMessage(fromEmail, toEmail, subject, content);
msg.IsBodyHtml = true;
var smtp = new SmtpClient(smtpServer)
{
Port = portNumber,
EnableSsl = true,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(userName, password)
};
ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };
smtp.Send(msg);
isSent = true;
}
catch (Exception ex)
{
}
return isSent;
}
protected void btnSelectUserSendTheDetails_Click(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder();
foreach (GridViewRow row in GvApproveStudent.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
CheckBox chkStatus = (CheckBox)row.Cells[18].FindControl("chkStatus");
if (chkStatus != null && chkStatus.Checked)
{
string UserId = row.Cells[7].Text;
string password = row.Cells[8].Text;
string EmailAddress = row.Cells[11].Text;
chkStatus.Text = "Approved";
bool ApproveStatus = chkStatus.Checked;
string constr = @"Data Source=198.71.226.6;Initial Catalog=ritsindia_MuraliIIT;User ID=RITS;Password=rits@1234";
string query = "UPDATE NewStudentRegistrationForm SET ApproveStatus = @ApproveStatus WHERE UserId = @UserId";
SqlConnection con = new SqlConnection(constr);
con.Open();
SqlCommand com = new SqlCommand(query, con);
com.CommandType = CommandType.Text;
com.Parameters.Add("@ApproveStatus", SqlDbType.Bit).Value = ApproveStatus;
com.Parameters.Add("@UserId", SqlDbType.Char).Value = UserId;
com.ExecuteNonQuery();
con.Close();
sb.Append("Please check below data
");
");
sb.Append("Hi,
Your Username is: " + UserId + "
Your Password is: " + password + "
");
Your Username is: " + UserId + "
Your Password is: " + password + "
");
bool result = SendEmail("[email protected]", EmailAddress, "Hello", sb.ToString(), " [email protected]", "rits@1234", "relay-hosting.secureserver.net", 25);
}
}
Bind_Data();
}
}
}
4 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.

Venkata SubbareddyPosted Jun 6, 2015, 6:51 AM
Afzaal Ahmad ZeeshanPosted Jun 6, 2015, 6:41 AM
- What is the problem?
- Which frameworks are provided
- Which libraries are provided or which need to be included
Ask these questions to them to get to know what is the problem and how you can overcome it.Venkata SubbareddyPosted Jun 6, 2015, 5:11 AM
Afzaal Ahmad ZeeshanPosted Jun 6, 2015, 3:45 AM