|
hey guys hope i think this is not so hard but i cant solve it yet
i have a webpage with a lot of txtboxes and i whant the value that is in that txtboxes to be inserted in a database the problem is that they worked with a ODBC driver first to insert in a other database but now i whanne edit it in SQL server the only problem is that i have this connection to insert it now but i dont realy know what i need 2 edit in the code
this is the original code from it - private void Opslaan()
-
{
-
localhost1.dbConnection dbConn = new localhost1.dbConnection();
-
string Klant = ddlKlant.SelectedItem.Text;
-
string Leverancier = ddlLeverancier.SelectedItem.Text;
-
txtRef.Text = GenReferentieNr(txtRef.Text);
-
if (imgBtnVerzamelSave.Visible == true)
-
dbConn.AddVerzamelblad(Functions.DateToUS(txtDatum.Text), txtRef.Text, Leverancier, txtTAV.Text, txtLevFax.Text, Klant, txtContact.Text, txtKlantFax.Text, txtDebetNr.Text, (txtOmschrijving.Text).Replace("'","`"), (txtAantal1.Text).Replace("'","`"), (txtArtikel1.Text).Replace("'","`"), (txtBestelNr1.Text).Replace("'","`"), txtOnzePrijs1.Text, txtPrijsKlant1.Text, (txtLevTijd1.Text).Replace("'","`"), txtAantal2.Text, (txtArtikel2.Text).Replace("'","`"), (txtBestelNr2.Text).Replace("'","`"), txtOnzePrijs2.Text, txtPrijsKlant2.Text, (txtLevTijd2.Text).Replace("'","`"), txtAantal3.Text, (txtArtikel3.Text).Replace("'","`"), (txtBestelNr3.Text).Replace("'","`"), txtOnzePrijs3.Text, txtPrijsKlant3.Text, (txtLevTijd3.Text).Replace("'","`"), txtAantal4.Text, (txtArtikel4.Text).Replace("'","`"), (txtBestelNr4.Text).Replace("'","`"), txtOnzePrijs4.Text, txtPrijsKlant4.Text, (txtLevTijd4.Text).Replace("'","`"), txtAantal5.Text, (txtArtikel5.Text).Replace("'","`"), (txtBestelNr5.Text).Replace("'","`"), txtOnzePrijs5.Text, txtPrijsKlant5.Text, (txtLevTijd5.Text).Replace("'","`"), txtAantal6.Text, (txtArtikel6.Text).Replace("'","`"), (txtBestelNr6.Text).Replace("'","`"), txtOnzePrijs6.Text, txtPrijsKlant6.Text, (txtLevTijd6.Text).Replace("'","`"), txtAantal7.Text, (txtArtikel7.Text).Replace("'","`"), (txtBestelNr7.Text).Replace("'","`"), txtOnzePrijs7.Text, txtPrijsKlant7.Text, (txtLevTijd7.Text).Replace("'","`"), txtAantal8.Text, (txtArtikel8.Text).Replace("'","`"), (txtBestelNr8.Text).Replace("'","`"), txtOnzePrijs8.Text, txtPrijsKlant8.Text, (txtLevTijd8.Text).Replace("'","`"), txtAantal9.Text, (txtArtikel9.Text).Replace("'","`"), (txtBestelNr9.Text).Replace("'","`"), txtOnzePrijs9.Text, txtPrijsKlant9.Text, (txtLevTijd10.Text).Replace("'","`"), txtAantal10.Text, (txtArtikel10.Text).Replace("'","`"), (txtBestelNr10.Text).Replace("'","`"), txtOnzePrijs10.Text, txtPrijsKlant10.Text, (txtLevTijd10.Text).Replace("'","`"), txtWinst.Text, "0", true);
-
else
-
dbConn.AddVerzamelblad(Functions.DateToUS(txtDatum.Text), txtRef.Text, Leverancier, txtTAV.Text, txtLevFax.Text, Klant, txtContact.Text, txtKlantFax.Text, txtDebetNr.Text, (txtOmschrijving.Text).Replace("'","`"), (txtAantal1.Text).Replace("'","`"), (txtArtikel1.Text).Replace("'","`"), (txtBestelNr1.Text).Replace("'","`"), txtOnzePrijs1.Text, txtPrijsKlant1.Text, (txtLevTijd1.Text).Replace("'","`"), txtAantal2.Text, (txtArtikel2.Text).Replace("'","`"), (txtBestelNr2.Text).Replace("'","`"), txtOnzePrijs2.Text, txtPrijsKlant2.Text, (txtLevTijd2.Text).Replace("'","`"), txtAantal3.Text, (txtArtikel3.Text).Replace("'","`"), (txtBestelNr3.Text).Replace("'","`"), txtOnzePrijs3.Text, txtPrijsKlant3.Text, (txtLevTijd3.Text).Replace("'","`"), txtAantal4.Text, (txtArtikel4.Text).Replace("'","`"), (txtBestelNr4.Text).Replace("'","`"), txtOnzePrijs4.Text, txtPrijsKlant4.Text, (txtLevTijd4.Text).Replace("'","`"), txtAantal5.Text, (txtArtikel5.Text).Replace("'","`"), (txtBestelNr5.Text).Replace("'","`"), txtOnzePrijs5.Text, txtPrijsKlant5.Text, (txtLevTijd5.Text).Replace("'","`"), txtAantal6.Text, (txtArtikel6.Text).Replace("'","`"), (txtBestelNr6.Text).Replace("'","`"), txtOnzePrijs6.Text, txtPrijsKlant6.Text, (txtLevTijd6.Text).Replace("'","`"), txtAantal7.Text, (txtArtikel7.Text).Replace("'","`"), (txtBestelNr7.Text).Replace("'","`"), txtOnzePrijs7.Text, txtPrijsKlant7.Text, (txtLevTijd7.Text).Replace("'","`"), txtAantal8.Text, (txtArtikel8.Text).Replace("'","`"), (txtBestelNr8.Text).Replace("'","`"), txtOnzePrijs8.Text, txtPrijsKlant8.Text, (txtLevTijd8.Text).Replace("'","`"), txtAantal9.Text, (txtArtikel9.Text).Replace("'","`"), (txtBestelNr9.Text).Replace("'","`"), txtOnzePrijs9.Text, txtPrijsKlant9.Text, (txtLevTijd10.Text).Replace("'","`"), txtAantal10.Text, (txtArtikel10.Text).Replace("'","`"), (txtBestelNr10.Text).Replace("'","`"), txtOnzePrijs10.Text, txtPrijsKlant10.Text, (txtLevTijd10.Text).Replace("'","`"), txtWinst.Text, lblNoteID.Text, false);
-
}
and this is what i made from it so far - private void Opslaan()
-
{
-
localhost1.dbConnection dbConn = new localhost1.dbConnection();
-
string Klant = ddlKlant.SelectedItem.Text;
-
string Leverancier = ddlLeverancier.SelectedItem.Text;
-
txtRef.Text = GenReferentieNr(txtRef.Text);
-
if (imgBtnVerzamelSave.Visible == true)
-
cmd.CommandText = "insert into verzamelblad values('" + txtRef + "','" + Leverancier + "','" + txtTAV + "','" + txtLevFax + "','" + Klant + "','" + txtContact + "','" + txtKlantFax + "','" + txtDebetNr + "','" + txtOmschrijving + "','" + txtAantal + "','" + txtArtikel1 + "','" + txtBestelnr1 + "','" + txtOnzePrijs1 + "','" + txtPrijsKlant1 + "','" + txtLevTijd1 + "','" + txtArtikel2 + "','" + txtBestelnr2 + "','" + txtOnzePrijs2 + "','" + txtPrijsKlant2 + "','" + txtLevTijd2 + "','" + txtArtikel3 + "','" + txtBestelnr3 + "','" + txtOnzePrijs3 + "','" + txtPrijsKlant3 + "','" + txtLevTijd3 + "','" + txtArtikel4 + "','" + txtBestelnr4 + "','" + txtOnzePrijs4 + "','" + txtPrijsKlant4 + "','" + txtLevTijd4 + "','" + txtArtikel5 + "','" + txtBestelnr5 + "','" + txtOnzePrijs5 + "','" + txtPrijsKlant5 + "','" + txtLevTijd5 + "','" + txtArtikel6 + "','" + txtBestelnr6 + "','" + txtOnzePrijs6 + "','" + txtPrijsKlant6 + "','" + txtLevTijd6 + "','" + txtArtikel7 + "','" + txtBestelnr7 + "','" + txtOnzePrijs7 + "','" + txtPrijsKlant7 + "','" + txtLevTijd7 + "','" + txtArtikel8 + "','" + txtBestelnr8 + "','" + txtOnzePrijs8 + "','" + txtPrijsKlant8 + "','" + txtLevTijd8 + "','" + txtArtikel9 + "','" + txtBestelnr9 + "','" + txtOnzePrijs9 + "','" + txtPrijsKlant9 + "','" + txtLevTijd9 + "','" + txtArtikel10 + "','" + txtBestelnr10 + "','" + txtOnzePrijs10 + "','" + txtPrijsKlant10 + "','" + txtLevTijd10 + "')";
-
else
-
cmd.CommandText = "insert into verzamelblad values('" + txtRef + "','" + Leverancier + "','" + txtTAV + "','" + txtLevFax + "','" + Klant + "','" + txtContact + "','" + txtKlantFax + "','" + txtDebetNr + "','" + txtOmschrijving + "','" + txtAantal + "','" + txtArtikel1 + "','" + txtBestelnr1 + "','" + txtOnzePrijs1 + "','" + txtPrijsKlant1 + "','" + txtLevTijd1 + "','" + txtArtikel2 + "','" + txtBestelnr2 + "','" + txtOnzePrijs2 + "','" + txtPrijsKlant2 + "','" + txtLevTijd2 + "','" + txtArtikel3 + "','" + txtBestelnr3 + "','" + txtOnzePrijs3 + "','" + txtPrijsKlant3 + "','" + txtLevTijd3 + "','" + txtArtikel4 + "','" + txtBestelnr4 + "','" + txtOnzePrijs4 + "','" + txtPrijsKlant4 + "','" + txtLevTijd4 + "','" + txtArtikel5 + "','" + txtBestelnr5 + "','" + txtOnzePrijs5 + "','" + txtPrijsKlant5 + "','" + txtLevTijd5 + "','" + txtArtikel6 + "','" + txtBestelnr6 + "','" + txtOnzePrijs6 + "','" + txtPrijsKlant6 + "','" + txtLevTijd6 + "','" + txtArtikel7 + "','" + txtBestelnr7 + "','" + txtOnzePrijs7 + "','" + txtPrijsKlant7 + "','" + txtLevTijd7 + "','" + txtArtikel8 + "','" + txtBestelnr8 + "','" + txtOnzePrijs8 + "','" + txtPrijsKlant8 + "','" + txtLevTijd8 + "','" + txtArtikel9 + "','" + txtBestelnr9 + "','" + txtOnzePrijs9 + "','" + txtPrijsKlant9 + "','" + txtLevTijd9 + "','" + txtArtikel10 + "','" + txtBestelnr10 + "','" + txtOnzePrijs10 + "','" + txtPrijsKlant10 + "','" + txtLevTijd10 + "')";
-
cmd.ExecuteNonQuery();
-
conn.Close();
-
}
the errors point at CMD and CONN
there maybe some misctacks made in the txtbox nameing but i am sure i can solve that my self if somone would be kind enouf to solve the connection i can do the rest my self i think
Tnx
| |
Share:
|
Lets call it an Update of the code XD - private void Opslaan()
-
{
-
string Klant = ddlKlant.SelectedItem.Text;
-
string Leverancier = ddlLeverancier.SelectedItem.Text;
-
txtRef.Text = GenReferentieNr(txtRef.Text);
-
if (imgBtnVerzamelSave.Visible == true)
-
SqlConnection Conn = new SqlConnection();
-
Conn.ConnectionString = @"Integrated Security = true; Initial Catalog=DB_visitid; Data Source=W2K3-01";
-
Conn.Open();
-
-
SqlCommand cmd = new SqlCommand();
-
cmd.Connection = Conn;
-
cmd.CommandText = "insert into offerte values ('"+Ref+"', '"+Leverancier+"', '"+TAV+"', '"+LevFax+"', '"+Klant+"', '"+Contact+"', '"+KlantFax+"', '"+Debetnr+"', '"+Omschrijving+"', '"+Aantal1+"', '"+Artikel1+"', '"+Bestelnr1+"', '"+OnzePrijs1+"', '"+PrijsKlant1+"', '"+LevTijd1+"', '"+Aantal2+"', '"+Artikel2+"', '"+Bestelnr2+"', '"+OnzePrijs2+"', '"+PrijsKlant2+"', '"+LevTijd2+"', '"+Aantal3+"', '"+Artikel3+"', '"+Bestelnr3+"', '"+OnzePrijs3+"', '"+PrijsKlant3+"', '"+LevTijd3+"', '"+Aantal4+"', '"+Artikel4+"', '"+Bestelnr4+"', '"+OnzePrijs4+"', '"+PrijsKlant4+"', '"+LevTijd4+"', '"+Aantal5+"', '"+Artikel5+"', '"+Bestelnr5+"', '"+OnzePrijs5+"', '"+PrijsKlant5+"', '"+LevTijd5+"', '"+Aantal6+"', '"+Artikel6+"', '"+Bestelnr6+"', '"+OnzePrijs6+"', '"+PrijsKlant6+"', '"+LevTijd6+"', '"+Aantal7+"', '"+Artikel7+"', '"+Bestelnr7+"', '"+OnzePrijs7+"', '"+PrijsKlant7+"', '"+LevTijd7+"', '"+Aantal8+"', '"+Artikel8+"', '"+Bestelnr8+"', '"+OnzePrijs8+"', '"+PrijsKlant8+"', '"+LevTijd8+"', '"+Aantal9+"', '"+Artikel9+"', '"+Bestelnr9+"', '"+OnzePrijs9+"', '"+PrijsKlant9+"', '"+LevTijd9+"', '"+Aantal10+"', '"+Artikel10+"', '"+Bestelnr10+"', '"+OnzePrijs10+"', '"+PrijsKlant10+"', '"+LevTijd10+"')";
-
Conn.Close();
-
}
so this is what i have now but i still get 1 error that says ( Embedded statement cannot be a declaration or labeled statement ) on rule 7 if i gues it good its about this line
SQLCONNECTION CONN = new SqlConnection(); and the error only points at the capslock letters
if anyone has solution i would love 2 hear it XD
| | Expert 2GB |
I think this is more of an ASP question than SQL Server.
Have you tried the ASP forum yet?
-- CK
| | Post your reply Sign in to post your reply or Sign up for a free account.
Similar topics
12 posts
views
Thread by Pete..... |
last post: by
|
reply
views
Thread by Colin MacDougall |
last post: by
|
1 post
views
Thread by Alex |
last post: by
|
1 post
views
Thread by vla75 |
last post: by
|
1 post
views
Thread by Michael |
last post: by
|
5 posts
views
Thread by trig |
last post: by
| | | | | | | | | | | | | | |