Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

c# mysql query

MySqlConnection con = new MySqlConnection(connectionString);
con.Open();
MySqlCommand cmd = new MySqlCommand("SELECT * FROM customers",con);
MySqlDataReader reader = cmd.ExecuteReader();
	while (reader.Read())
	{
    	//You can get values from column names
    	Console.WriteLine(reader["customerName"].ToString());
      	//Or return the value from the columnID, in this case, 0
    	Console.WriteLine(reader.GetInt32(0));
	}
con.Close();
 
PREVIOUS NEXT
Tagged: #mysql #query
ADD COMMENT
Topic
Name
6+2 =