Socarsky
Well-known member
- Joined
- Mar 3, 2014
- Messages
- 59
- Programming Experience
- Beginner
What's wrong in my code that cause a crach when I click on the combobox arrow
private void ConnPervasive() { Form1.populate(); getDBname = Form1.passDBname; // Pervasive Sql connection string string ConnStrPSql = "Server Name=XXXXX;Database Name=" + getDBname + ";User ID=administrator;Password=XXXXXXX;"; using (PsqlConnection conn = new PsqlConnection(ConnStrPSql)) { try { conn.Open(); string strPSqlCmd1 = "SELECT A.R_KAYNAKKODU as Tezgah, B.AD as TezgahAdi FROM xxx A LEFT OUTER JOIN xxxx B ON A.R_KAYNAKKODU = B.KOD WHERE A.EVRAKNO = '" + AddWhiteSpace(txtMPS.Text) + "' AND A.ACIK_KAPALI = '' AND B.AD <> ''"; using (PsqlCommand command = new PsqlCommand(strPSqlCmd1, conn)) { DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("Tezgah", typeof(string))); dt.Columns.Add(new DataColumn("TezgahAdi", typeof(string))); PsqlDataReader reader = command.ExecuteReader(CommandBehavior.Default); DataRow myRow; while (reader.Read()) { myRow = dt.NewRow(); myRow.ItemArray[0] = reader[0]; myRow.ItemArray[1] = reader[1]; dt.Rows.Add(myRow); } reader.Close(); comboBox1.DisplayMember = "Tezgah"; comboBox1.DrawMode = DrawMode.OwnerDrawVariable; comboBox1.ColumnWidths = "50;150"; comboBox1.DataSource = dt; comboBox1.Text = String.Empty; if (dt != null && dt.Rows.Count > 0) { MessageBox.Show("Harika bir kac kayit var"); } else { MessageBox.Show("==> There is not any record in Database! \n ~~> Tidak ada itu MPS nomor dalam Database!"); } } } catch { MessageBox.Show("Database Connection Problem Occurred!."); } } }