المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Link textbox to postgresql database



C# Programming
07-06-2009, 07:11 AM
Hi! how am i suppose to do if i wan to search the data in the database by typing the info in the textbox and it will show the information onto the comboBox?

For example, I type the Employee name into the textbox, then from there, it will search the database and show the contact number of the employee in the combobox.

Is there any way to do it?
I tried using npgsql.dll but it keeps giving errors?
This is the code that i used :
string strConnString = "Server=remote_server;Port=5432;User Id=john;Password=john;Database=testserver";
try
{
NpgsqlConnection objConn = new NpgsqlConnection(strConnString);
objConn.Open();
string strSelectCmd = "SELECT MachineID FROM MachineDeviceMatrix";
NpgsqlDataAdapter objDataAdapter = new NpgsqlDataAdapter(strSelectCmd, objConn);
objDataAdapter.Fill(this.MachineDeviceMatrix);
objConn.Close();
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message, "Error message", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

please help, thanks!