In this article I will explain executereader executenonquery executescalar examples when to use what in asp.net using C#.net and VB.NET.
|
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
Subscribe by RSS
Subscribe by Email
|
|||
|
|
Subscribe by RSS
Subscribe by Email
3 comments :
namespace example1
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string cs = "server=CHANDANA;database=chandana;Uid=sa;Password=sa123";
SqlConnection con = new SqlConnection(cs);
string com = "Select FirstName,MiddleName,LastName from emply";
SqlDataAdapter adpt = new SqlDataAdapter(com, con);
DataSet myDataSet = new DataSet();
adpt.Fill(myDataSet, "emply");
DataTable myDataTable = myDataSet.Tables[0];
DataRow tempRow = null;
foreach (DataRow tempRow_Variable in myDataTable.Rows)
{
tempRow = tempRow_Variable;
ListBox1.Items.Add((tempRow["FirstName"] + " (" + tempRow["MiddleName"] + ")" + " (" + tempRow["LastName"] + ")"));
}
}
protected void Button1_Click(object sender, EventArgs e)
{
if (ListBox1.SelectedItem != null)
{
ListItem li = ListBox1.SelectedItem;
ListBox1.Items.Remove(li);
li.Selected = false;
ListBox2.Items.Add(li);
}
}
protected void Button2_Click(object sender, EventArgs e)
{
if (ListBox2.SelectedItem != null)
{
ListItem li = ListBox2.SelectedItem;
ListBox2.Items.Remove(li);
li.Selected = false;
ListBox1.Items.Add(li);
}
}
//protected void Button3_Click(object sender, EventArgs e)
//{
// ListBox1.Items.Add(TextBox1.Text);
//}
}
}
Very insightful!
I do not really understand the C#.net language.