3 messages in com.mysql.lists.dotnetRE: Important Problems
FromSent OnAttachments
nil...@aon.at15 Feb 2005 13:24 
Kevin Turner16 Feb 2005 01:29 
Kevin Turner17 Feb 2005 03:03 
Subject:RE: Important Problems
From:Kevin Turner (kevi@coraltree.co.uk)
Date:02/17/2005 03:03:27 AM
List:com.mysql.lists.dotnet

You can try using the "Allow Zero Dates=True" option on the connection string,
but as has been pointed out to me by numerous people, it is better not to use
NULL or zero dates on your database - use 1,1,1 instead. I must say I have
stopped using zero and null dates because it always ends up biting you in the
end. I just have a wad of static functions to handles dates and treat 1,1,1 as
if it were null or zero.

-----Original Message----- From: nil@aon.at [mailto:nil@aon.at] Sent: 15 February 2005 21:24 To: dot@lists.mysql.com Subject: Important Problems

Hi everybody!

Sorry, but I have another problem. Today I tested my first program. Unfortunately, there are some errors. Hope anyone could help me!

I will post the whole code:

private void Page_Load(object sender, System.EventArgs e) { Label2.Text = Convert.ToString(Session["name"]); Label7.Text = Convert.ToString(Session["autor"]); Label8.Text = Convert.ToString(Session["genre"]); Label9.Text = Convert.ToString(Session["verlag"]);

string command = "SELECT * from books where Titel like '%"+Label2.Text+"%'"; string cs = "Data Source = localhost; DATABASE = bibliothek; User Id = root; PASSWORD=****;";

MySql.Data.MySqlClient.MySqlConnection con = new MySql.Data.MySqlClient.MySqlConnection(cs); MySql.Data.MySqlClient.MySqlCommand test = new MySql.Data.MySqlClient.MySqlCommand(command,con); MySql.Data.MySqlClient.MySqlDataAdapter da = new MySql.Data.MySqlClient.MySqlDataAdapter(command,cs);

con.Open(); da.Fill(ds); // <- Error (*) DataBind(); con.Close(); con.Dispose(); }

My problems are follows:

1) (*) -> There seems to be a convert error: "Unable to convert MySQL date/time value to System.DateTime How can I solve that problem?

2) How can I manage the command? Because as you can see, I have 4 Labels. I want to combine all of those in one command. But I think there will be errors, if one of these Labels is empty. Hard to describe, I'll give an example: Label2.Text = "Book"; Label7.Text = "Me"; Label8.Text = "Horror"; Label9.Text = "blabla";

For this, there should be a command like: "SELECT * from (books,autor,genre,verlag) where (Name,Autor,Titel,Verlag) like ('%"+Label2.Text+"%','%"+Label7.Text+"%','%"+Label8.Text+"%','%"+Label9.Text+"%'");

Is this command possible ?? AND, if one of the Labels is empty, for example Label8.Text = ""; , would this command still work?

Sorry for my bad english, I hope you understand. Please help me, it's very important! This program is for my final exams, and I really need to get this thing done! Thanks a lot! Regards, Gerrit