将Oracle中表数据导入到Access中的相应表的时候碰到带有'号数据怎么办自己写代码进行数据的导入,用拼SQL的语句的方法,但是碰到有的数据有带有'号,导致SQL语句出错
Access好象又不支持还有参数化的SQL语句,怎么解决这个问题啊,

解决方案 »

  1.   

    string + "'" + ...
      

  2.   

    赫赫 大概明白你的意思
    如果自己写代码的化应该没问题吧,两个连接,一个连接oracle 一个access
    从oracle取得数据,更新到access中。
    表结构用class代替,多条数据用List<class>,或者datatable,dataset等,然后就更新把。
    绑拟定,等高人把。
      

  3.   

    请看这篇文章:http://blog.csdn.net/zhoufoxcn/archive/2008/03/19/2195618.aspx
    部分代码如下:using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Data.OleDb;/// <summary>
    /// 在Access中使用参数化SQL的例子
    /// 代码编写:周公
    /// 日期:2008-3-19
    /// 发表网址:http://blog.csdn.net/zhoufoxcn/archive/2008/03/19/2195618.aspx
    /// </summary>
    public class AccessUtil
    {
        public AccessUtil()
        {
            
        }    public bool InsertAdmin(string userName, string password, string re, string mail, int departId, int power)
        {
            string sql = "insert into S_Admin(UserName,Password,Re,Mail,DepartId,Power)values(?,?,?,?,?,?)";
            OleDbConnection connection = new OleDbConnection();
            connection.ConnectionString = "";//此处设置链接字符串
            //注意下面参数的顺序一定要按照sql语句中的插入的列的顺序赋值,否则一定会报异常
            OleDbCommand command = new OleDbCommand(sql, connection);
            command.Parameters.Add("?", OleDbType.LongVarWChar, 60).Value = userName;
            command.Parameters.Add("?", OleDbType.LongVarWChar, 60).Value = password;
            command.Parameters.Add("?", OleDbType.LongVarWChar, 60).Value = re;
            command.Parameters.Add("?", OleDbType.LongVarWChar, 60).Value = mail;
            command.Parameters.Add("?", OleDbType.Integer, 4).Value = departId;
            command.Parameters.Add("?", OleDbType.Integer, 4).Value = power;
            connection.Open();
            int rowsAffected = command.ExecuteNonQuery();
            connection.Close();
            command.Dispose();
            return rowsAffected > 0;
        }
    }需要说明的是,除了Access之外,操作其它数据库可以不必要按照参数在SQL语句中出现的顺序添加进去一样可以正确执行,但是在Access中一定按照插入的列的顺序添加参数,因为“OLE DB.NET Framework 数据提供程序使用标有问号 (?) 的定位参数,而不使用命名参数(MSDN)”,所以给添加参数和赋值一定要按照列的顺序。