Click here to Skip to main content
15,748,477 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
i have been trying to import a dataset to y microsoft SQL server it keeps giving me this error messege
"SQL Server Import and Export Wizard
The operation could not be completed.
The ConnectionString property has not been initialized. (System.Data)"
what do i do?

What I have tried:

I have tried resetting the App
Updated 20-Feb-23 5:38am
Dave Kreskowiak 20-Feb-23 11:27am    
You start by showing your code. The error message is pretty clear. You haven't given the code a connection string to use to tell it how to connect to your database server.
Dave Kreskowiak 20-Feb-23 11:39am    
If this is in the Import/Export Wizard, you may have told it how to connect to one database to either read from or write to, but not the other database.

1 solution

The error message is pretty clear:
The ConnectionString property has not been initialized. (System.Data)
It means what it says: you haven't provided the Connection string which tells the system which instance of SQL Server you want to connect to.

It's like trying to call someone without dialling their number: the phone service doesn't know who you want to speak to, so they can't connect the call.

We have no idea what language you are coding in, but here's an example for C#:
string strConnect = "Data Source=MyInstanceOfSqlServer;Initial Catalog=MyDB;Integrated Security=True";
using (SqlConnection con = new SqlConnection(strConnect))
    using (SqlCommand cmd = new SqlCommand("SELECT Age, Description FROM myTable WHERE ID = @ID", con))
        cmd.Parameters.AddWithValue("@ID", myTextBox.Text);
        using (SqlDataReader reader = cmd.ExecuteReader())
            while (reader.Read())
                int age = (int) reader["Age"];
                string desc = (string) reader["Description"];
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900