/// <summary>
/// 更新数据
/// </summary>
/// <param name="strSql"></param>
public static int ExecuteNonQuery(string strSql)
{
int count = -1;
OleDbConnection myConn = new OleDbConnection(strConn);
OleDbCommand myComm = new OleDbCommand(strSql,myConn);
try
{
myConn.Open();
count = myComm.ExecuteNonQuery();
}
catch(Exception e)
{

}
finally
{
if(myConn.State != ConnectionState.Closed)
myConn.Close();
myComm.Dispose();
myConn.Dispose();
}
return count;
}

解决方案 »

  1.   

    using System.Data;
    using System.Data.OleDb;
    ---------------------------
    OleDbConnection thisConnection=new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\D\DevCs\Works2\Person.mdb;");
    thisConnection.Open();
    OleDbCommand thisCommand=thisConnection.CreateCommand(); //
    thisCommand.CommandText="SELECT * FROM Intro";
    OleDbDataReader thisReader=thisCommand.ExecuteReader();
    while(thisReader.Read())
    {
    Console.WriteLine("\t{0}\t{1}",thisReader["ID"],thisReader["TheName"]);
    }
    thisReader.Close();
    thisConnection.Close();