protected void wbtn_find_Click(object sender, EventArgs e)
{
string where = "";
string text = Textname.Text;
for (int i = 0; i < text.Length; i++)
{
string ss = text.Substring(0, 1);
where += "(District_Name LIKE '%" + ss + "%')";
if (i < text.Length - 1)
{
where += " OR ";
}
}
string str = @"SELECT District_Name, District_Code
FROM dbo.D_DISTRICT_MAST
WHERE " + where;
SqlConnection sqlCon = new SqlConnection("data source=.;database=HMMS;uid=sa;pwd=");
SqlCommand sqlCmd = new SqlCommand(str, sqlCon);
sqlCon.Open();
SqlDataReader myReader = sqlCmd.ExecuteReader();
while (myReader.Read())
{
int i = 0;
TextBox.Text = myReader.GetValue(i).ToString();
i++;
}
myReader.Close();
sqlCon.Close();
}
TextBox.Text += myReader.GetValue(i).ToString();