Example #1
0
        private void LookupDB(string key)
        {
            frmLookup frm = new frmLookup();

            frm.Text    = key;
            frm.Connect = txtConnect.Text;
            if (frm.ShowDialog() == DialogResult.OK)
            {
                string tableName = frm.ReturnCode;
                if (tableName != "")
                {
                    txtDescription.Text = txtLookup.Text = txtCode.Text = tableName;

                    DataTable kq = new DataTable();
                    System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(frm.Connect);
                    try
                    {
                        conn.Open();
                        kq = conn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Columns, new Object[] { null, null, tableName, null });
                        //dgvField.AutoGenerateColumns = true;
                        _dtField.Clear();
                        for (int i = 0; i < kq.Rows.Count; i++)
                        {
                            DataRow row    = kq.Rows[i];
                            DataRow newRow = _dtField.NewRow();
                            newRow["Key"] = newRow["DataMember"] = newRow["Caption"] = row["COLUMN_NAME"];

                            if (row["DATA_TYPE"].ToString() == "135")
                            {
                                newRow["DataTypeCode"] = "DateTime";
                            }
                            else if (row["DATA_TYPE"].ToString() == "5")
                            {
                                newRow["DataTypeCode"] = "Double";
                            }
                            else
                            {
                                newRow["DataTypeCode"] = "String";
                            }
                            newRow["Visible"]    = "True";
                            newRow["Position"]   = (i + 1).ToString();
                            newRow["IsNull"]     = row["IS_NULLABLE"];
                            newRow["PrimaryKey"] = "False";
                            //newRow["Tag"] = "";
                            _dtField.Rows.Add(newRow);
                        }
                        //dgvField.DataSource = kq;
                    }
                    catch { }
                    finally { conn.Close(); }
                    dgvField.AutoSizeColumns();
                }
            }
        }
Example #2
0
        private void LookupDB(string key)
        {
            frmLookup frm = new frmLookup();

            frm.Text    = key;
            frm.Connect = txtConnect.Text;
            if (frm.ShowDialog() == DialogResult.OK)
            {
                string tableName = frm.ReturnCode;
                if (tableName != "")
                {
                    txtCode.Text = tableName;
                    _code        = txtCode.Text.Trim();
                    DataTable kq = new DataTable();
                    System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(frm.Connect);
                    try
                    {
                        conn.Open();
                        kq = conn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Columns, new Object[] { null, null, tableName, null });
                        //dgvField.AutoGenerateColumns = true;
                        _data.Tables["_TableName"].Clear();
                        _data.Tables["fromcode"].Clear();
                        DataRow rowtable = _data.Tables["fromcode"].NewRow();
                        rowtable["fromcode"] = rowtable["lookup"] = tableName;
                        _data.Tables["fromcode"].Rows.Add(rowtable);
                        foreach (DataRow row in kq.Rows)
                        {
                            DataRow newRow = _data.Tables["_TableName"].NewRow();
                            newRow["table"] = tableName;
                            newRow["node"]  = newRow["name"] = row["COLUMN_NAME"];
                            if (row["DATA_TYPE"].ToString() == "135")
                            {
                                newRow["type"] = "D";
                            }
                            else if (row["DATA_TYPE"].ToString() == "5")
                            {
                                newRow["type"] = "N";
                            }
                            _data.Tables["_TableName"].Rows.Add(newRow);
                        }
                        //dgvField.DataSource = kq;
                    }
                    catch { }
                    finally { conn.Close(); }
                    dgvField.AutoSizeColumns();
                    dgvFrom.AutoSizeColumns();
                }
            }
        }