Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Error while connecting to SQL server in connection String

$
0
0

Hello All,

I am using VS 2010, C# windows forms. I am trying to connect VS to SQL server and display the data of the selected table in the DataGrid. I am connecting to SQL server using windows login. Unfortunately,it is showing error near Initial Catalog. The error states: "ArgumentException was unhandled: Unknown connection option in the connection string: initial catalog".

Below is my code:

private void button2_Click(object sender, EventArgs e)
        {
            SqlCeConnection con = new SqlCeConnection("Data Source=MyPC;Initial Catalog=Example;Integrated Security=True");
            con.Open();
            SqlCeDataAdapter sda = new SqlCeDataAdapter("select * from Student", con);
            DataTable dt = new DataTable();
            sda.Fill(dt);
            dataGridView1.DataSource = dt;
        }

Please tell me where I am gone wrong and what I need to correct.

Regards,

Humaira.


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>