I've made an aspx master pages following learnvisualstudio video for input email into database, but this doesn't work.
here is the code:
protected void submitButton_Click(object sender, EventArgs e)
{
SqlDataSource NewsSource = new SqlDataSource();NewsSource.ConnectionString =
ConfigurationManager.ConnectionStrings["NewsConnectionString1"].ToString();NewsSource.InsertCommandType =
SqlDataSourceCommandType.Text;NewsSource.InsertCommand =
"INSERT INTO Email (EmailAddress, IPAddress, DateTimeStamp) VALUES (@EmailAddress, @IPAddress, @DateTimeStamp)";
NewsSource.InsertParameters.Add(
"EmailAddress", emailAddressTextBox.Text);NewsSource.InsertParameters.Add(
"IPAddress", Request.UserHostAddress.ToString());NewsSource.InsertParameters.Add(
"DateTimeStamp", DateTime.Now.ToString());int rowsAffected = 0;
try
{
rowsAffected = NewsSource.Insert();
}
catch (Exception ex){
Server.Transfer(
"news_problem.aspx");}
finally{
gameNewsSource =
null;}
if (rowsAffected != 1){
Server.Transfer(
"news_problem.aspx");}
else{
Server.Transfer(
"news_confirm.aspx");}
}