View Single Post
05-30-2009, 03:15 AM
#4
lonelyrider is offline lonelyrider
Status: I'm new around here
Join date: May 2009
Location:
Expertise:
Software:
 
Posts: 18
iTrader: 0 / 0%
 

lonelyrider is on a distinguished road

  Old

Well theres two ways this can be done articture wise

Connected one has already been posted

Disconnected one

//i hope you know how a connection String is formed
SqlConnection con=new SqlConnection(connectionString);
//data set holds the schema
DataSet ds=new DataSet();
SqlDataAdapter da=new SqlDataAdapter("select * from db",con);
da.Fill("tablename");
//Command builder builds the command for you
SqlCommandBuilder cbd=new SqlCommandBuilder(da);
//data table holds a particular table
DataTable dt=ds.Tables["tablename"];

// add a new blank row
DataRow dr=dt.Rows.Add();
//start adding rows
dr[0]="Primary key";
dr[1]="name";
dr[2]=double.Parse(textBox1.Text);
//done? then commit the row
int rowAdded=da.Update("tablename");
Response.Write(rowAdded.ToString()+" no. of rows added");

Reply With Quote