hey guys hope you can help me with this error
with this button i whanne add values from an ASP webpage into my SQL database and i get an error on line 7 ( Embedded statement cannot be a declaration or labeled statement ) and the red line is only on the first Sql connection but not onder Conn
I dont now if you need this code with it nut i maybe a easeyer to understand
with this button i whanne add values from an ASP webpage into my SQL database and i get an error on line 7 ( Embedded statement cannot be a declaration or labeled statement ) and the red line is only on the first Sql connection but not onder Conn
Code:
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(); }
Code:
private void imgBtnUpdate_Click(object sender, System.Web.UI.ImageClickEventArgs e) { Opslaan(); Server.Transfer("VerzamelStatus.aspx?ID=" + txtRef.Text); }
Comment