Danelo Danelo - 9 days ago 5
MySQL Question

Microsoft Visual Studio SQL server connection - invalid pointer

enter image description here

So, I want to create a SQL database in Microsoft SQL Management Studio and connect it to Microsoft Visual Studio. I linked the database to Visual Studio and it worked. Now, I want to open that connection to test it with a button on a windows form application. Every time I try, it says "invalid pointer" but the database name is correct. I don't know what is wrong.

I still get the invalid pointer error...My instance name is DESKTOP-BJSAO6B but it doesnt seem to work...

Answer

You need provide a proper connection string like

string connectionString =
        "data source=.\SQLEXPRESS;initial catalog=student;integrated security=True;";


    using (SqlConnection connection =
        new SqlConnection(connectionString))
{
 connection.Open();
 MessageBox.Show("You are connected");
 }

where SQLEXPRESS - name your MSSQL instance ( may be different). More you can see here