Adding SqlServer Database to MFC dialog based application

844 Views Asked by At

I have some code in c# that can connect to a sqlserver database and display the data on a datagridview:

SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\UVSS\\Documents\\CommPortDB.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
conn.Open();            
var adapter = new SqlDataAdapter("Select * from UVSSTable1", conn);
var table = new DataTable();
adapter.Fill(table);
this.dataGridView1.DataSource = table;

How do I use the same in an MFC dialog based application in c++? I have referred to this previous question, but it doesn't seem to cover what I need to know.

0

There are 0 best solutions below