一些数据连接:What I have done in the past year:my old code "DataSet"
来源:互联网 发布:长期服用知柏地黄丸 编辑:程序博客网 时间:2024/04/30 07:31
1 Save Changes into DataBase
string strDSN = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D://pxf.accdb";
string strSQL = "SELECT * FROM Table1";
OleDbConnection myConn = new OleDbConnection(strDSN);
OleDbDataAdapter myCmd = new OleDbDataAdapter(strSQL, myConn);
DataSet dtSet = new DataSet();
myConn.Open();
myCmd.Fill(dtSet, "Table1");
DataTable dTable = dtSet.Tables[0];
DataRow dr = dTable.NewRow();
dr["name"] = textBox1.Text;
dTable.Rows.Add(dr);
OleDbCommandBuilder myb = new OleDbCommandBuilder(myCmd);
myCmd.Update(dtSet, "Table1");
myConn.Close();
2 DataGridView and DataSet
string connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D://mctest.mdb";
OleDbConnection myConnection = new OleDbConnection();
myConnection.ConnectionString = connString;
OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM Developer", myConnection);
DataSet ds = new DataSet();
da.Fill(ds, "Developer");
dataGridView1.DataSource = ds.Tables[0];
3 Touch OleDb
string strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D://mcTest.MDB";
OleDbConnection myConn = new OleDbConnection(strDSN);
string strSQL = "SELECT * FROM Developer";
OleDbCommand myCmd = new OleDbCommand(strSQL, myConn);
OleDbDataReader datareader = null;
myConn.Open();
datareader = myCmd.ExecuteReader();
while (datareader.Read())
{
Console.WriteLine("Developer Name:{0}, Address:{1},Salary:{2}", datareader["Name"], datareader["Address"],datareader["Salary"]);
}
myConn.Close();
- 一些数据连接:What I have done in the past year:my old code "DataSet"
- What I have done
- What would you have done in my shoes?
- What have I done for?
- What I have done on...
- What I Have Done In 2005 And What I Should Do In 2006
- What have I done these days?
- What I have done as a DBA
- me: the past year
- 英文歌曲:What I Have Done(变形金刚第一部主题曲)
- What have you done to the Earth, hackers?
- What I have learnt from System Life Cycle and How it influence my progress in my IA
- What I've done
- What is the best(funniest) comment in source code you have ever encountered?
- What is the best comment in source code you have ever encountered? [closed]
- What I Have Learned From My First Scientific Research
- The Summary of 100 & the past year.
- What the past told me......
- SQL Cursor DB2
- 3G应用---windows mobile和symbian平台下rtsp流媒体播放器
- ubuntu下支持ibus中文输入的笔记软件Xournal
- Spring学习笔记3——AOP
- VC---Wa t c h 窗口使用
- 一些数据连接:What I have done in the past year:my old code "DataSet"
- C宏定义使用
- 决策树:排序问题的计算复杂性
- 必看人生道路上的100个真相
- SDRAM的寻址知识及重要的参数
- Ubuntu下开发环境的搭建
- 简单模型剖析Spring管理Bean的原理
- 今天心情很不错
- Windows Mobile中的WebService应用