Hi Good Guy,
I am very surprised of the coding generate error message
Error 1 Use of unassigned local variable 'strSql'
even though the strSQL variable was declared. Not sure what is wrong with the overall coding;
Here are the coding:
Thank You.
Cheers,
Lennie
I am very surprised of the coding generate error message
Error 1 Use of unassigned local variable 'strSql'
even though the strSQL variable was declared. Not sure what is wrong with the overall coding;
Here are the coding:
Code:
private void FLoadDataGridView()
{
string strSql;
if (this.radioBtnAll.Checked == true)
{
strSql = "Select * from Customers Order by CustomerID";
}
if (this.radioBtnSome.Checked == true)
{
strSql = "Select * from Customers ";
strSql += "Where CustomerID like 'this.txtSome.Text%'";
strSql += "Order by CustomerID ";
}
sqlConn = new SqlConnection(connStr);
sqlConn.Open();
[B] DA = new SqlDataAdapter(strSql, sqlConn); <---- Error [/B]
DS = new DataSet("DS");
DA.Fill(DS,"Customer");
dataGridView1.DataSource = DS.Tables["Customer"];
dataGridView1.ClearSelection();
sqlConn.Close();
DS.Dispose();
}
Thank You.
Cheers,
Lennie
Comment