国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 盱眙县| 兰坪| 汝城县| 济阳县| 密云县| 阜新市| 宜昌市| 漳浦县| 如东县| 城固县| 红原县| 临猗县| 芒康县| 通化县| 石城县| 达孜县| 永济市| 陈巴尔虎旗| 开平市| 兴海县| 共和县| 南雄市| 沈丘县| 新邵县| 会昌县| 四子王旗| 莒南县| 河南省| 阿克苏市| 绥滨县| 昆明市| 绍兴市| 武定县| 开化县| 蕉岭县| 宜章县| 余姚市| 苏尼特左旗| 哈尔滨市| 饶河县| 平塘县|