Click here to Skip to main content
15,898,538 members

Comments by JohnUSA (Top 34 by date)

JohnUSA 7-Dec-10 18:45pm View    
Deleted
thanks, just figure it! great help! :)
JohnUSA 7-Dec-10 18:19pm View    
Deleted
Hello again,

string conn1 = "SERVER=test;" + "DATABASE=books;" + "UID=db;" + "PASSWORD=abc;";
MySqlConnection conn = null;
MySqlCommand comm = null;
MySqlDataReader reader = null;
List<string> priceList = new List<string>();
string sql = "SELECT * FROM Books";
try
{
conn = new MySqlConnection(ConfigurationManager.ConnectionStrings[conn1].ConnectionString);
conn.Open();
comm = new MySqlCommand(sql, conn);
reader = comm.ExecuteReader();
while (reader.Read())
{
priceList.Add(reader["Price"].ToString());
}
}
finally
{
if (reader != null)
{
reader.Close();
}
if (conn != null)
{
conn.Dispose();
}
}

foreach (string s in priceList)
{
Console.WriteLine(s);
}

I am missing something? i get an error on:
conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString);
which is: Object reference not set to an instance of an object.
JohnUSA 7-Dec-10 17:16pm View    
Deleted
Hello,

i have done:
List<int> priceResults = new List<int>();
string conn = "SERVER=test;" + "DATABASE=books;" + "UID=db;" + "PASSWORD=abc;";
MySqlConnection conne= new MySqlConnection(conn);
MySqlCommand command = connection.CreateCommand();
MySqlDataReader Reader;
try
{
conne.Open();
command.CommandText = "SELECT Price FROM BooksTB WHERE Author ='" + author + "' AND ISBN ='" + ISBN + "'";
Reader = command.ExecuteReader();
while (Reader.Read())
{
priceResults.Add(mySqlReader["Price"].ToString());
}
conne.Close();
}
catch (Exception e)
{
Console.WriteLine("{0} Exception caught.", e);
}
but i can't save each one in differnet string! can you help me pls?
JohnUSA 4-Dec-10 18:29pm View    
How this will help ?
JohnUSA 4-Dec-10 18:22pm View    
Exactly the same error again!!!
You have no idea what else to try ?