标题:c#如何修改Access中的数据
取消只看楼主
eric_wjh
Rank: 1
等 级:新手上路
帖 子:76
专家分:0
注 册:2008-7-29
 问题点数:0 回复次数:5 
c#如何修改Access中的数据
版主 我用insert into values语句怎么修改不了的
OleDbCommand myOleDbCommand = new OleDbCommand("Insert into db2 values('sfd','jkl','hf','jy');", myOleDbConection);
搜索更多相关主题的帖子: Access 数据 
2008-07-30 10:15
eric_wjh
Rank: 1
等 级:新手上路
帖 子:76
专家分:0
注 册:2008-7-29
得分:0 
对啊 不知道“而且;好象是没有的吧.”是什么意思啊
还请教下
2008-07-30 10:20
eric_wjh
Rank: 1
等 级:新手上路
帖 子:76
专家分:0
注 册:2008-7-29
得分:0 
不是;代表语句结束啊
2008-07-30 10:27
eric_wjh
Rank: 1
等 级:新手上路
帖 子:76
专家分:0
注 册:2008-7-29
得分:0 
我试过了大侠的方法 但是还是出错啊
不知道为什么啊
string connectionString =
               "provider=Microsoft.Jet.OLEDB.4.0;" +
               "data source=C:\\Documents and Settings\\Administrator.310C7DBA925B462\\桌面\\db2.mdb";
            OleDbConnection myOleDbConection = new OleDbConnection(connectionString);
            OleDbCommand myOleDbCommand = new OleDbCommand("Insert into db2(customerID, CompanyName, contactName, Address) values('sfd','jkl','hf','jy');", myOleDbConection);/*SELECT customerID, CompanyName, contactName, Address "+
"FROM db2 "+
"WHERE (((customerID)='ALFKI'));", myOleDbConection);*/
            
           /* string sql;
            sql = "SELECT customerID, CompanyName, contactName, Address " +
"FROM db2 " +
"WHERE (((customerID)='ALFKI'));" + "CREAT TABLE 学生 (学号 CHAR(5) NOT NULL UNIQUE,姓名 CHAR(8) NOT NULL,年龄 SMALLINT,性别 CHAR(2),所在系 CHAR(20));";// +
//"DEFOAULT C1 20 FOR 年龄,CONSTRAINT C2 CHECK (性别 IN('男','女')));";
            OleDbCommand myOleDbCommand = new OleDbCommand(sql, myOleDbConection);*/


            /*OleDbCommand myOleDbCommand = myOleDbConection.CreateCommand();//new OleDbCommand("select * from db2", myOleDbConection);
             =
                "SELECT customerID,CompanyName,contactName,Adress " +
                "FROM db2 " +
                "WHERE cunstomerID ='ALFKI';";*/
            myOleDbConection.Open();
            OleDbDataReader myOleDbDataReader = myOleDbCommand.ExecuteReader();

            OleDbCommand myOleDbCommand1 = new OleDbCommand("SELECT customerID, CompanyName, contactName, Address " +
"FROM db2 " +
"WHERE (((customerID)='ALFKI'));", myOleDbConection);
            //myOleDbConection.Open();
            OleDbDataReader myOleDbDataReader1 = myOleDbCommand1.ExecuteReader();

            myOleDbDataReader.Read();
            Console.WriteLine(myOleDbDataReader1["customerID"]);
            Console.WriteLine(myOleDbDataReader1["CompanyName"]);
            Console.WriteLine(myOleDbDataReader1["contactName"]);
            Console.WriteLine(myOleDbDataReader1["Address"]);
            myOleDbDataReader1.Close();
            myOleDbConection.Close();
            string wait = Console.ReadLine();
2008-07-30 10:45
eric_wjh
Rank: 1
等 级:新手上路
帖 子:76
专家分:0
注 册:2008-7-29
得分:0 
哦?那改数据是什么指令啊
望赐教
2008-07-30 14:21
eric_wjh
Rank: 1
等 级:新手上路
帖 子:76
专家分:0
注 册:2008-7-29
得分:0 
嗯 修改成功
谢谢大侠
2008-07-30 14:51



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-225889-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.526181 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved