Posts

Showing posts with the label ASP.Net and ADO.net

ADO.net notes and data adapter

ADO.NET ADO.NET is the latest extension of the Universal Data Access technology. Its architecture is similar to classic ADO in some respects, but a great departure in others.ADO.NET is much simpler, less dependent on the data source, more flexible, and the format of data is textual instead of binary. Textual formatted data is more verbose than binary formatted data, and this makes it comparably larger. The tradeoff is ease of transportation through disconnected networks, flexibility, and speed. www.syngress.com Because data in ADO.NET is based on XML, Managed Providers are required to serve data in a proper XML format. Once a developer has written data access code, they only need to change a few parameters to connect to a different data source. ADO.NET is based on a connection-less principle that is designed to ease the connection limitations that developers have traditionally had to deal with when creating distributed solutions. You no longer nee

1. High Level Commission for Information Technology, Singh Durbar, Kathmandu, Nepal

1. High Level Commission for Information Technology, Singh Durbar, Kathmandu, Nepal What is the e-Government? A Government which accepts information and communication technologies as a tools to transform its internal and external relationships and processes in governance to be more effective, transparent, professional and costing less to its citizens. In another terms, e-Government can be viewed as the process of creating public value with the use of Modern ICT. Indian Ministry of Communications and information Technology defines electronic governance ‘the application of information Technology to the processes of government functioning to bring about simple, moral, accountable, responsive and transparent government. Therefore, e-Government is the same government that applies ICT for its transformation to deliver better public services. The value added by the government is the difference between the benefits that the public eventually enjoys and the resources and powers that citizens de

Complete Program To insert, update, show and delete in .Net using ADO

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; namespace databaseinsertion { public partial class Form1 : Form { int myid; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { string constr = "Data Source=NOBEL-PC\\SQLEXPRESS;Initial Catalog=db_ecommerce;user id=rupak;password=rupak"; SqlConnection sqlcon = new SqlConnection(constr); SqlCommand scmd = new SqlCommand("productinsertion", sqlcon); scmd.CommandType = CommandType.StoredProcedure; scmd.Parameters.AddWithValue("@names", textBox1.Text); scmd.Parameters.AddWithValue("@description", richTextBox1.Text); try {

delete with the use of stored procedure code in .net and sql

private void button4_Click(object sender, EventArgs e) { string constr = "Data Source=NOBEL-PC\\SQLEXPRESS;Initial Catalog=db_ecommerce;user id=rupak;password=rupak"; SqlConnection sqlcon = new SqlConnection(constr); string query = "deleteproduct"; SqlCommand scmd = new SqlCommand(query, sqlcon); scmd.CommandType = CommandType.StoredProcedure; scmd.Parameters.AddWithValue("@id", myid); try { sqlcon.Open(); scmd.ExecuteNonQuery(); MessageBox.Show("Data Deleted"); } catch (SqlException se) { MessageBox.Show(se.Message); } sqlcon.Close(); }

Update code in .net using stored procedure

private void button2_Click(object sender, EventArgs e) { string constr = "Data Source=NOBEL-PC\\SQLEXPRESS;Initial Catalog=db_ecommerce;user id=rupak;password=rupak"; SqlConnection sqlcon = new SqlConnection(constr); string product_name = textBox1.Text; string product_description = richTextBox1.Text; string query = "updateproduct"; SqlCommand scmd = new SqlCommand(query, sqlcon); scmd.CommandType = CommandType.StoredProcedure; scmd.Parameters.AddWithValue("@id",myid); // MessageBox.Show(myid.ToString()); scmd.Parameters.AddWithValue("@names", product_name); scmd.Parameters.AddWithValue("@description", richTextBox1.Text); try { sqlcon.Open(); scmd.ExecuteNonQuery(); MessageBox.Show("Data Updated"); }

Click in the listView and type the code to see data from the richTextBox and textbox

private void listView1_SelectedIndexChanged(object sender, EventArgs e) { if (listView1.SelectedItems.Count > 0) { ListViewItem lv = listView1.SelectedItems[0]; myid=Convert.ToInt32(lv.Tag); textBox1.Text = lv.Text; richTextBox1.Text = lv.SubItems[1].Text; } }

button code to insert data into database with the use of store procedure

button code to insert data into database with the use of store procedure .net code private void button1_Click(object sender, EventArgs e) { string constr = "Data Source=thismaydiffer\\SQLEXPRESS;Initial Catalog=db_name;user id=usernamerupak;password=userpasswordrupak"; SqlConnection sqlcon = new SqlConnection(constr); SqlCommand scmd = new SqlCommand("productinsertion", sqlcon); scmd.CommandType = CommandType.StoredProcedure; scmd.Parameters.AddWithValue("@names", textBox1.Text); scmd.Parameters.AddWithValue("@description", richTextBox1.Text); try { sqlcon.Open(); scmd.ExecuteNonQuery(); MessageBox.Show("Data Inserted"); } catch (SqlException se) { MessageBox.Show(se.Message); } sqlcon.Close(); }