C#DataGrid的Oracle连接字符串

时间:2014-05-17 14:50:16

标签: c# oracle database-connection

当我在连接字符串中将数据集导入应用程序时,我选择"不从连接字符串中排除信息。我将在我的应用程序中设置此信息"。

现在当我编译表单时,在DataGrid中没有什么可看的,我必须在我的应用程序中连接到connet?

现在我有:

 public Form1()
        {
            InitializeComponent();

            using (OracleConnection con = new OracleConnection("Data Source=localhost;Persist Security Info=True;User ID=martynas;Password=xxxxxxx;Unicode=True"))
            {
                try
                {
                    con.Open();
                    OracleCommand cmd = new OracleCommand();
                    cmd.Connection = con;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }

此连接已打开,但DataGridView仍未显示任何记录。我想也许我用错误的方法连接?

1 个答案:

答案 0 :(得分:1)

您没有将OracleCommand连接到任何东西。你创建它但当它超出范围时,它就不再存在了。