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;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void DropDownList5_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void Clear_Click(object sender, EventArgs e)
{
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
TextBox6.Text = "";
TextBox7.Text = "";
TextBox8.Text = "";
TextBox9.Text = "";
TextBox10.Text = "";
TextBox11.Text = "";
RadioButtonList1.SelectedValue = null;
TextBox12.Text = "";
DropDownList4.SelectedValue = null;
DropDownList5.SelectedValue = null;
CheckBox1.Checked = false;
Label21.Text = "";
}
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
}
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlDataReader dr;
SqlConnection con = new SqlConnection("Data Source=SARANYA-TS02\\SQLEXPRESS;Initial Catalog=ss;Integrated Security=True");
SqlCommand cmd = new SqlCommand("insert into RegistrationForm values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text
+ "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox8.Text + "','" + RadioButtonList1.SelectedValue
+ "','" + TextBox12.Text + "','" + TextBox9.Text + "','" + TextBox10.Text
+ "','" + TextBox11.Text + "','" + DropDownList4.SelectedValue + "','" + DropDownList5.SelectedValue + "')", con);
con.Open();
cmd.ExecuteNonQuery();
SqlCommand cc = new SqlCommand("select from RegistrionForm where e-mail Address");
cc.ExecuteNonQuery();
}
protected void RadioButton2_CheckedChanged(object sender, EventArgs e)
{
}
protected void TextBox7_TextChanged(object sender, EventArgs e)
{
}
protected void TextBox2_TextChanged(object sender, EventArgs e)
{
}
protected void TextBox3_TextChanged(object sender, EventArgs e)
{
}
protected void TextBox9_TextChanged(object sender, EventArgs e)
{
}
}
this is my code i want to modify n email id... after i click submit button if that email id is already exists means i ve to throw exception.... plz help me
Vishnujeet KumarPosted Dec 11, 2012, 7:01 AM
SqlConnection con = new SqlConnection("Data Source=SARANYA-TS02\\SQLEXPRESS;Initial Catalog=ss;Integrated Security=True");
string Sqlquery = "SELECT * FROM RegistrationForm where E-mail_Address=" + TextBox7.Text + "'";
con.Open();
SqlCommand com = new SqlCommand(Sqlquery, con);
SqlDataReader reader = com.ExecuteReader();
try
{
if (!reader.Read())
{
SqlCommand cmd = new SqlCommand("insert into RegistrationForm values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text
+ "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox8.Text + "','" + RadioButtonList1.SelectedValue
+ "','" + TextBox12.Text + "','" + TextBox9.Text + "','" + TextBox10.Text
+ "','" + TextBox11.Text + "','" + DropDownList4.SelectedValue + "','" + DropDownList5.SelectedValue + "')", con);
cmd.ExecuteNonQuery();
}
else
{
MessageBox.Show(" EmailId already exists");
}
reader.Close();
con.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
saranya SPosted Dec 12, 2012, 1:15 AM
saranya SPosted Dec 11, 2012, 6:57 AM
Vishnujeet KumarPosted Dec 11, 2012, 6:56 AM
saranya SPosted Dec 11, 2012, 6:52 AM
saranya SPosted Dec 11, 2012, 6:33 AM
Vishnujeet KumarPosted Dec 11, 2012, 6:21 AM
saranya SPosted Dec 11, 2012, 6:12 AM
Vishnujeet KumarPosted Dec 11, 2012, 6:11 AM
string Sqlquery = "SELECT * FROM RegistrationForm where EmailId='" + txtEmailid.Text + "'";
SqlCommand com = new SqlCommand(Sqlquery, con);
con.Open();
SqlDataReader reader = com.ExecuteReader();
Vishnujeet KumarPosted Dec 11, 2012, 6:06 AM
SqlCommand com = new SqlCommand(Sqlquery, con);
saranya SPosted Dec 11, 2012, 6:01 AM
saranya SPosted Dec 11, 2012, 5:46 AM
Vishnujeet KumarPosted Dec 11, 2012, 5:26 AM
string Sqlquery = "SELECT * FROM RegistrationForm where EmailId='" + txtEmailid.Text + "'";
SqlCommand com = new SqlCommand("Sqlquery", con);
SqlDataReader reader = new SqlDataReader();
con.Open();
reader = com.ExecuteReader;
try
{
if (!reader.Read)
{
SqlCommand cmd = new SqlCommand("insert into RegistrationForm values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text
+ "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox8.Text + "','" + RadioButtonList1.SelectedValue
+ "','" + TextBox12.Text + "','" + TextBox9.Text + "','" + TextBox10.Text
+ "','" + TextBox11.Text + "','" + DropDownList4.SelectedValue + "','" + DropDownList5.SelectedValue + "')", con);
con.Open();
cmd.ExecuteNonQuery();
}
else
{
MessageBox.Show (" EmailId already exists");
}
reader.Close();
con.Close();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
saranya SPosted Dec 11, 2012, 4:42 AM
i didnt use grid view n all.. plz help me....
Vishnujeet KumarPosted Dec 11, 2012, 3:23 AM
http://www.c-sharpcorner.com/Forums/Thread/195693/using-grid-view-how-to-check-vendor-name-already-exists.aspx