private void
DocNamePopUp()
{
AutoCompleteStringCollection DataCollection = new AutoCompleteStringCollection();
getData(DataCollection);
txtDocName.AutoCompleteSource = AutoCompleteSource.CustomSource;
txtDocName.AutoCompleteCustomSource = DataCollection;
}
private void getData(AutoCompleteStringCollection dataCollection)
{
string connetionString = null;
SqlConnection connection;
SqlCommand command;
SqlDataAdapter adapter = new
SqlDataAdapter();
DataSet ds = new DataSet();
using(SqlConnection connection
= new SqlConnection(CS));
try
{
connection.Open();
command = new SqlCommand("spGetDoctorNames", connection);
command.CommandType = CommandType.StoredProcedure;
adapter.SelectCommand = command;
adapter.Fill(ds);
adapter.Dispose();
command.Dispose();
foreach
(DataRow row in
ds.Tables[0].Rows)
{
dataCollection.Add(row[0].ToString());
}
}
catch (Exception
ex)
{
MessageBox.Show("Can not open connection ! ");
}
}
No comments:
Post a Comment