473,404 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

SQL connetion in C# page

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

Expand|Select|Wrap|Line Numbers
  1.     private void Opslaan()
  2.         {
  3.         string Klant = ddlKlant.SelectedItem.Text;
  4.         string Leverancier = ddlLeverancier.SelectedItem.Text;
  5.         txtRef.Text = GenReferentieNr(txtRef.Text);
  6.             if (imgBtnVerzamelSave.Visible == true)
  7.             SqlConnection Conn = new SqlConnection();
  8.             Conn.ConnectionString = @"Integrated Security = true; Initial Catalog=DB_visitid; Data Source=W2K3-01";
  9.             Conn.Open();
  10.  
  11.             SqlCommand cmd = new SqlCommand();
  12.             cmd.Connection = Conn;
  13.             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+"')";
  14.             Conn.Close();
  15.         }
I dont now if you need this code with it nut i maybe a easeyer to understand

Expand|Select|Wrap|Line Numbers
  1. private void imgBtnUpdate_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  2.         {
  3.             Opslaan();
  4.             Server.Transfer("VerzamelStatus.aspx?ID=" + txtRef.Text);
  5.         }
Oct 27 '08 #1
2 1026
JosAH
11,448 Expert 8TB
This is the C and C++ forum. These languages have nothing to do with C#. I'll move
your thread to the .NET forum where the C# questions are asked and answered.

kind regards,

Jos (moderator)
Oct 27 '08 #2
Well i ges i solved the error a bit logicly if i look at it now i still get another error but i first will look at it my self if i cant solve it youl here it here again Tnx for the help for the peaple whoe whanne see what i changed here is the code

Expand|Select|Wrap|Line Numbers
  1.     private void Opslaan()
  2.         {
  3.         string Klant = ddlKlant.SelectedItem.Text;
  4.         string Leverancier = ddlLeverancier.SelectedItem.Text;
  5.         txtRef.Text = GenReferentieNr(txtRef.Text);
  6.         if (imgBtnVerzamelSave.Visible == true)
  7.         {
  8.             SqlConnection Conn = new SqlConnection();
  9.             Conn.ConnectionString = @"Integrated Security = true; Initial Catalog=DB_visitid; Data Source=W2K3-01";
  10.             Conn.Open();
  11.             SqlCommand cmd = new SqlCommand();
  12.             cmd.Connection = Conn;
  13.             cmd.CommandText = "insert into offerte values ('" + txtRef + "', '" + Leverancier + "', '" + txtTAV + "', '" + txtLevFax + "', '" + Klant + "', '" + txtContact + "', '" + txtKlantFax + "', '" + txtDebetNr + "', '" + txtOmschrijving + "', '" + txtAantal1 + "', '" + txtArtikel1 + "', '" + txtBestelNr1 + "', '" + txtOnzePrijs1 + "', '" + txtPrijsKlant1 + "', '" + txtLevTijd1 + "', '" + txtAantal2 + "', '" + txtArtikel2 + "', '" + txtBestelNr2 + "', '" + txtOnzePrijs2 + "', '" + txtPrijsKlant2 + "', '" + txtLevTijd2 + "', '" + txtAantal3 + "', '" + txtArtikel3 + "', '" + txtBestelNr3 + "', '" + txtOnzePrijs3 + "', '" + txtPrijsKlant3 + "', '" + txtLevTijd3 + "', '" + txtAantal4 + "', '" + txtArtikel4 + "', '" + txtBestelNr4 + "', '" + txtOnzePrijs4 + "', '" + txtPrijsKlant4 + "', '" + txtLevTijd4 + "', '" + txtAantal5 + "', '" + txtArtikel5 + "', '" + txtBestelNr5 + "', '" + txtOnzePrijs5 + "', '" + txtPrijsKlant5 + "', '" + txtLevTijd5 + "', '" + txtAantal6 + "', '" + txtArtikel6 + "', '" + txtBestelNr6 + "', '" + txtOnzePrijs6 + "', '" + txtPrijsKlant6 + "', '" + txtLevTijd6 + "', '" + txtAantal7 + "', '" + txtArtikel7 + "', '" + txtBestelNr7 + "', '" + txtOnzePrijs7 + "', '" + txtPrijsKlant7 + "', '" + txtLevTijd7 + "', '" + txtAantal8 + "', '" + txtArtikel8 + "', '" + txtBestelNr8 + "', '" + txtOnzePrijs8 + "', '" + txtPrijsKlant8 + "', '" + txtLevTijd8 + "', '" + txtAantal9 + "', '" + txtArtikel9 + "', '" + txtBestelNr9 + "', '" + txtOnzePrijs9 + "', '" + txtPrijsKlant9 + "', '" + txtLevTijd9 + "', '" + txtAantal10 + "', '" + txtArtikel10 + "', '" + txtBestelNr10 + "', '" + txtOnzePrijs10 + "', '" + txtPrijsKlant10 + "', '" + txtLevTijd10 + "')";
  14.             Conn.Close();
  15.         }
  16.         }
Oct 27 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Michael Brennan-White | last post by:
If I submit my for using a get action the resulting page loads . If I use a post action I get an error page saying "The page cannot be found". I am calling the originating page!!! This happens...
0
by: Nathan | last post by:
Hi, I seem to having a peculiar problem with the display of odd and even pages in XSL-FO. Here is a small background of the problem. My xsl stylesheet mentions my fo:layout-master-set as ...
2
by: James | last post by:
I've been to websites where if I navigate off a form, trying to get back to it by hitting the back button gives me a page which says "Warning, page has expired". It doesn't display the page. I've...
4
by: Kevin Phifer | last post by:
Ok, before anyone freaks out, I have a solution I need to create that gathers content from maybe different places. Each one can return a <form> in the html, so its the classic can't have more than...
2
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
6
by: MooreSmnith | last post by:
When I navigate to the next page using Response.Rediect("MyNextPage.aspx") current page Page_Load event is called. What I may wrongly understood is that post back will happen whenever there is any...
1
by: Lenard Gunda | last post by:
Hi! I have the following problem. From my main page, when someone clicks a button, it uses client side javascript to open another .aspx page. This page displays content, based on what the...
5
by: tshad | last post by:
Is there a way to carry data that I have already read from the datagrid from page to page? I am looking at my Datagrid that I page through and when the user says get the next page, I have to go...
7
by: UJ | last post by:
I've got a page with a user control on it. While the page is loading, it needs to check certain conditions of the user object to enable/disable things on the screen. Currently in the page_load of...
4
by: Sakcee | last post by:
Hi this is really a stupid question, how can i get page rsponse from a site e.g. google.com port 80 form socket, can i do something import socket s = socket.socket( socket.AF_INET,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.