public void Button1_Click(object sender, EventArgs e)
{
String a = DropDownList1.SelectedItem.Value;
String b = DropDownList3.SelectedItem.Value.PadLeft(3, '0');
String c = TextBox1.Text.PadLeft(5, '0').ToString();
String d = TextBox2.Text.ToString();
String digit = a + b + c + d;
try
{
OdbcConnection casetype = new OdbcConnection("Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=testcase;User=root;Password=root;Option=3;");
casetype.Open();
//************to get case type
string casetypequery = "select casename from casetype where skey=?";
//************to get case type
OdbcCommand casetypecmd = new OdbcCommand(casetypequery, casetype);
String casetypefromdropdown = DropDownList3.SelectedItem.ToString();
casetypecmd.Parameters.AddWithValue("?", casetypefromdropdown);
using (OdbcDataReader casetypeMyReader = casetypecmd.ExecuteReader())
{
while (casetypeMyReader.Read())
{
String casename = casetypeMyReader["casename"].ToString();
}
}
}
catch (Exception ewa)
{
Response.Write(ewa);
}
I am not able to access
String casename = casetypeMyReader["casename"].ToString();
which is inside while loop in my above code. How can i access
'casename'
outside while loop?i want to use it to put the content in HtmlEditor(ajax)