G
Guest
I tried a sample of code in MSDN magazine, but now I'm stuck. What code has
the best performance to populate a Data Grid with a SP? Below is the code I
have, which might be completing the wrong way to populate a data grid. I
like using code and not the server explorer. (I replaced the sa password for
this post.)
private void frmDealerSearch_Load(object sender, System.EventArgs e)
{
string sConnString = "Data
Source=db;Database=License;Integrated Security=False;User
ID=sa;password=password";
string sProc = "prGet_DealerInfo";
using (SqlConnection oCn = new
SqlConnection(sConnString))
{
using (SqlCommand oCmd = new
SqlCommand(sProc, oCn))
{
oCn.Open();
oCmd.CommandType =
CommandType.StoredProcedure;
oDa.SelectCommand = oSelCmd;
dgDealerInfo.DataSource = oDa;
}
}
}
The following errors occur.
The type or namespace name 'oDa' could not be found (are you missing a
using directive or an assembly reference?)
The name 'oDa' does not exist in the class or namespace
'LicenseDealerSales.frmDealerSearch'
But you might have a better way to code to populate data grid.
the best performance to populate a Data Grid with a SP? Below is the code I
have, which might be completing the wrong way to populate a data grid. I
like using code and not the server explorer. (I replaced the sa password for
this post.)
private void frmDealerSearch_Load(object sender, System.EventArgs e)
{
string sConnString = "Data
Source=db;Database=License;Integrated Security=False;User
ID=sa;password=password";
string sProc = "prGet_DealerInfo";
using (SqlConnection oCn = new
SqlConnection(sConnString))
{
using (SqlCommand oCmd = new
SqlCommand(sProc, oCn))
{
oCn.Open();
oCmd.CommandType =
CommandType.StoredProcedure;
oDa.SelectCommand = oSelCmd;
dgDealerInfo.DataSource = oDa;
}
}
}
The following errors occur.
The type or namespace name 'oDa' could not be found (are you missing a
using directive or an assembly reference?)
The name 'oDa' does not exist in the class or namespace
'LicenseDealerSales.frmDealerSearch'
But you might have a better way to code to populate data grid.