国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數(shù)據(jù)庫 > Access > 正文

Add data to the Access database using ADO

2024-09-07 19:04:54
字體:
供稿:網(wǎng)友
?e1ú×?′óμ?web?a·¢×ê?′í????°??ê?é???£?
add data to the database using ado

tools used : visual c# .net

this program shows how to insert data in an access database using ado and sql query. i have an access 2000 database in project/bin/debug directory. my database name is mctest.mdb. you can create your own database and copy in your project's debug directory. i am not attaching database with this code because of size problem.

i have a table 'developer' in this database which has four columns. i am inserting values into two columns name and address in this code.

using system;
using system.data;   
using system.data.oledb;   
namespace adonetwritequery  
{
      /// <summary>
      /// summary description for class1.
      /// </summary>
      class class1
      {  
            static void main(string[] args)  
            {  
                  string strdsn = "provider=microsoft.jet.oledb.4.0;data
source=c://mctest.mdb";  
                  string strsql = "insert into developer(name, address ) values(
'newname', 'newaddress')" ;  
                   
                  // create objects of adoconnection and adocommand   
                  oledbconnection myconn = new oledbconnection(strdsn);  
                  oledbcommand mycmd = new oledbcommand( strsql, myconn );  
                  try  
                  {  
                        myconn.open();  
                        mycmd.executenonquery();  
                  }  
                  catch (exception e)  
                  {  
                        console.writeline("oooops. i did it again:/n{0}", e.message);  
                  }  
                  finally  
                  {  
                        myconn.close();  
                  }  
   
   
   
            }
      }  
}  
   





發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 淳化县| 巴东县| 黄浦区| 新沂市| 汾阳市| 武义县| 阳江市| 银川市| 旬邑县| 维西| 宁城县| 佛冈县| 清水河县| 那坡县| 海南省| 霍城县| 宜昌市| 会昌县| 芜湖市| 张家界市| 琼结县| 兴仁县| 定远县| 双桥区| 江源县| 黄龙县| 威宁| 巫山县| 罗山县| 平阴县| 凌源市| 榆林市| 灌云县| 凌源市| 厦门市| 南昌市| 浠水县| 金坛市| 绵阳市| 沙河市| 赤峰市|