Question: I'm trying to insert an entry into a table in visual studio (C# .Net), but after I run my code and then try to view
I'm trying to insert an entry into a table in visual studio (C# .Net), but after I run my code and then try to view the table I get this error message,
This database cannot be imported. It is either an unsupported SQL server version or an unsupported database compatibility.
Here is the code that is attempting to insert,
private void doneButton_Click(object sender, EventArgs e) { string userName = userNameTextBox.Text, password = passwordTextBox.Text, question = questionMenu.Text, answer = answerTextBox.Text; int key = EncryptionClass.generateKey(); SqlConnection connection = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\MyData.mdf;Integrated Security=True"); connection.Open(); String sqlQuery = "INSERT INTO dbo.Account(UserName, UserPassword, UserKey) " + "VALUES (\'" + userName + "\', \'" + EncryptionClass.encrypt(password, key) + "\', " + key + ");"; Console.WriteLine("string " + sqlQuery); // INSERT INTO dbo.Account(UserName, UserPassword, UserKey) VALUES ('victoramaro', 'obvmhkT1', 19); using (SqlCommand command = new SqlCommand(sqlQuery, connection)) { try { var res = command.ExecuteNonQuery(); } catch (SqlException ex) { Console.WriteLine(ex.Message); } } connection.Close(); } And the App.config,
In the properties of MyData.mdf Build Action is set to Content, Copy to Output Directory is set to Copy if newer.
In the properties of MyDataDataSet.xsd Build Action is set to None, Copy to Output Directory is set to Do not copy.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
