MySQL Forums
Forum List  »  Connector/ODBC

problems inserting data in database
Posted by: Kristof Van Bladel
Date: April 22, 2005 04:12AM

Hi,
I have some trouble iserting my data in my database using the ODBC drivers.
I get this error: System.Data.Odbc.OdbcException
it also says that it occured in System.odbc.dll
as extra information it says System error.
This is the code i use:
AddPersonen.Parameters ["Naam"].Value = Naam;
AddPersonen.Parameters ["Voornaam"].Value = Voornaam;
AddPersonen.Parameters ["Geb_Datum"].Value = Gebdatum;
// AddPersonen.CommandText = "INSERT INTO personen (Geb_Datum,Naam,Voornaam) VALUES (Gebdatum,Naam,Voornaam)";
AddPersonen.ExecuteNonQuery();

//Adres gegevens toevoegen (Straat, Nr en Postcode)
AddAdressen.Parameters ["Straat"].Value = Straat;
AddAdressen.Parameters ["Nr"].Value = Nr;
AddAdressen.Parameters ["Postcode"].Value = Postcode;
// AddAdressen.CommandText = "INSERT INTO adressen (Straat,Nr,Postcode) VALUES (Straat,NR,Postcode)";
AddAdressen.ExecuteNonQuery();

//Contactgegevens toevoegen (Email,Telefoon, Fax en Gsm)
AddContactgegevens.Parameters ["Email"].Value = Email;
AddContactgegevens.Parameters ["Tel"].Value = Tel;
AddContactgegevens.Parameters ["Fax"].Value = Fax;
AddContactgegevens.Parameters ["Gsm"].Value = Gsm;
// AddContactgegevens.CommandText = "INSERT INTO contactgegevens (Email,Tel,Fax,Gsm) VALUES (Email,Tel,Fax,Gsm)";
AddContactgegevens.ExecuteNonQuery();

//Kijken of de postcode en dus ook de gemeente al in de database staan
//en dan toevoegen als dat niet het geval is
try
{
CheckGemeenten.Parameters["Postcode"].Value = Postcode;
CheckGemeenten.ExecuteReader();
Gemeente2 =Convert.ToString(CheckGemeenten.Parameters ["Gemeente"]);
}
catch (Exception ex)
{
AddGemeenten.Parameters ["Postcode"].Value = Postcode;
AddGemeenten.Parameters ["Gemeente"].Value = Gemeente;
// AddGemeenten.CommandText = "INSERT INTO gemeenten (Postcode,Gemeente) VALUES (Postcode,Gemeente)";
AddGemeenten.ExecuteNonQuery();
}

I hope someone can help me
Thank you in advance,
Kristof

Options: ReplyQuote


Subject
Written By
Posted
problems inserting data in database
April 22, 2005 04:12AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.