alonestarsz

博客园 首页 新随笔 联系 订阅 管理
private void CallAccess()
        
{

            
string OLEDBConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};";
            
string resourcePath = filePath("100keypolluters.mdb");
            OLEDBConnStr 
= string .Format(OLEDBConnStr,resourcePath);
            
string strCreateTableSQL = "select count(*) from enterprises_05";
            OleDbConnection oConn 
= new OleDbConnection(); 
   
            oConn.ConnectionString 
= OLEDBConnStr; 
            OleDbCommand oCreateComm 
= new OleDbCommand();
            oCreateComm.Connection 
= oConn;
            oCreateComm.CommandText 
= strCreateTableSQL;

            oConn.Open(); 
            
object count = oCreateComm.ExecuteScalar();
            oConn.Close();

        }


        
private string filePath(string fileName) 
        
{
            
string resourcePath = Application.StartupPath;
            resourcePath 
= resourcePath.Replace(@"bin\Debug",@"resource\");
            resourcePath 
+= fileName;
            
return resourcePath;
        }
posted on 2005-11-16 14:54  天煞孤星  阅读(108)  评论(0编辑  收藏  举报