求教!!!这个要怎么改???
这串代码连接的是Access数据库,现求教高人,如何把他改为连接SQL数据库的!!!!!!!!(代码如下)namespace XXX
class DataAccess
{
private string strDSN;
OleDbConnection oledbCon;
public void dataCon()
{
strDSN="provider = Microsoft.Jet.OLEDB.4.0;Data.Source="+Application.StartupPath.ToString()"\\student.mdb";
oledbCon=new OleDbConnection(strDSN)
}
public DataSet getDataSet(string sql)
{
DataSet ds=new DataSet();
oledbCon.Open();
try
{
OleDbCommand oledbCom=new OleDbCommand(sql,oledbCon);
OleDbDataAdapter oledbDa=new OleDbDataAdapter(oledbCom);
oledbDa.Fill(ds);
return ds;
}
catch(Exception ex)
{
throw new Exception(ex.ToString());
}
finally
{
oledbCon.Close();
}
}
public bool sqlExec(string sql)
{
try
{
oledbCon.Open();
}
catch
{
MessageBox.Show("数据库未连接!");
}
try
{
OleDbCommand oledbCom=new OleDbCommand(sql,oledbCon);
oledbcom.ExecuteNonQuery();
return true;
}
catch(Execption ex)
{
MessageBox.Show(ex.Message,"提示");
return false;
}
finally
{
oledbCon.Close();
}
}
}
}