3
votes

For some reason, I couldn't find a good answer in google why this code dosent work:

MySqlConnection connection = new MySqlConnection("Databaseyeshuv1");
MySqlCommand command = connection.CreateCommand();
MySqlDataReader Reader;
command.CommandText =
  "SELECT * FROM `MASADE_FEA_bak2` WHERE `marom_num`        equals `3`";
connection.Open();
Reader = command.ExecuteReader();
while (Reader.Read())
{
  string line = Reader.GetString(1);
  this.שטח_קומה_מחושב.Text = line;
}
connection.Close();

This is the error I'm getting:

System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0. at System.Data.Common.DbConnectionOptions.GetKeyValuePair(String connectionString, Int32 currentPosition, StringBuilder buffer, Boolean useOdbcRules, String& keyname, String& keyvalue) at System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey) at System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules) at System.Data.Common.DbConnectionStringBuilder.set_ConnectionString(String value) at MySql.Data.MySqlClient.MySqlConnection.set_ConnectionString(String value) at MySql.Data.MySqlClient.MySqlConnection..ctor(String connectionString) at MyApp7.UI.Controls.ShowMASADE_FEA_bak2.KomotMASADE_FEA_bak2TableControlRow.Setשטח_קומה_מחושב()

1
new MySqlConnection("Databaseyeshuv1"); - what is thát?Konerak
that's the connection string from WebConfigEhud Grand
Quite apart from anything else, the equality operator in MySQL is not equals, but =.eggyal

1 Answers

1
votes

I think you made many mistake in your code:

  1. The string "Databaseyeshuv1" should be the connection string value, not the name. You should write some code to get that value from config file. Have a look at here
  2. In your command text, should use = instead of equals and remove the character quoting 3, so just use number 3 only.