|
public static bool InsertRowmy(string mdbPath, string tableName, ArrayList insertArray, DataRow dr)
{
try
{
//1、建立连接
string strConn = @"rovider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mdbPath + ";Jet OLEDBatabase Password=haoren";
OleDbConnection odcConnection = new OleDbConnection(strConn);
//2、打开连接
odcConnection.Open();
int size_col = insertArray.Count;
for (int i = 0; i < size_col; i++)
{
string ziduan = insertArray[i].ToString();
string neirong = dr[ziduan].ToString();
string sql = "insert into"+ tableName+"("+ziduan+") values ("+@neirong+")";
OleDbCommand odCommand = new OleDbCommand(sql, odcConnection);
if (ziduan != null)
{
odCommand.Parameters.Add(neirong, OleDbType.VarBinary, neirong.Length).Value = neirong.ToString();
//odCommand.Parameters.AddWithValue(ziduan, neirong);
//odCommand.Parameters.Add(new SqlParameter(@neirong, SqlDbType.NVarChar, 50));
}
odCommand.ExecuteNonQuery();
}
odcConnection.Close();
return true;
}
catch (Exception err)
{
// errinfo = err.Message;
return false;
}
}
运行报错 求大神帮忙????急急急!!!!
|
|