473,387 Members | 1,569 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,387 software developers and data experts.

Add Data to SQL database from a ASP webpage

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

Expand|Select|Wrap|Line Numbers
  1.         private void Opslaan()
  2.         {
  3.             localhost1.dbConnection dbConn = new localhost1.dbConnection();
  4.             string Klant = ddlKlant.SelectedItem.Text;
  5.             string Leverancier = ddlLeverancier.SelectedItem.Text;
  6.             txtRef.Text = GenReferentieNr(txtRef.Text);
  7.             if (imgBtnVerzamelSave.Visible == true)
  8.                 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);
  9.             else
  10.                 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);
  11.         }
and this is what i made from it so far

Expand|Select|Wrap|Line Numbers
  1.         private void Opslaan()
  2.         {
  3.             localhost1.dbConnection dbConn = new localhost1.dbConnection();
  4.             string Klant = ddlKlant.SelectedItem.Text;
  5.             string Leverancier = ddlLeverancier.SelectedItem.Text;
  6.             txtRef.Text = GenReferentieNr(txtRef.Text);
  7.             if (imgBtnVerzamelSave.Visible == true)
  8.                 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 + "')";
  9.             else
  10.                 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 + "')";
  11.             cmd.ExecuteNonQuery();
  12.             conn.Close();
  13.         }
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
Oct 23 '08 #1
2 1218
Lets call it an Update of the code XD

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.         }
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
Oct 23 '08 #2
ck9663
2,878 Expert 2GB
I think this is more of an ASP question than SQL Server.

Have you tried the ASP forum yet?

-- CK
Oct 24 '08 #3

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

Similar topics

12
by: Pete..... | last post by:
Hi all. I have made a webpage where there is a webform where people can fill in their personel information: The code is below: I want to transfer the data to a postgreSQL database ( I have...
0
by: Colin MacDougall | last post by:
Hello, In our company several of us have MS Access installed on our PC's. We would like the people without Access to be able to add data to a few tables held on our server - is it easy enough to...
1
by: Alex | last post by:
Hi, Everyday, I download data from a webpage and manually input data into my MS Access database. I am thinking of automate the routine by a VB script. The webpage I am visiting will return a...
1
by: vla75 | last post by:
Hi there, I made a webpage in asp.NET that access data trough Oledb and everything works fine if the webpage and the Olap database are on one and the same computer. When I moved the OLAP Database...
1
by: Michael | last post by:
I am using Visual Studio 2005 (ASP 2.0) to build a webpage that uses a Microsoft Access Database. The data in the database simply holds the information on a link to a document that I am storing on...
5
by: trig | last post by:
Please help! I am an ICT teacher at a secondary school and my year 12 (AS Level) group need to create a website where data can be sent from a form to a Microsoft Access database. I am trying...
2
by: rustyc | last post by:
Well, here's my first post in this forum (other than saying 'HI' over in the hi forum ;-) As I said over there: ... for a little side project at home, I'm writing a ham radio web site in...
1
by: yucefrizk | last post by:
hello all, I'm trying to write a code to retreive data from a database to an excel file, I achieved my code and everything is going good by running it through unix, but when I create a webpage to...
2
by: arawsg | last post by:
im new to sql and ive created a test data base with a test table having 3 input fields i was wondering if it was possible to use a webpage to input data into the database in a specific table ive...
5
sid0404
by: sid0404 | last post by:
Hi I am new to the visualstudio.net I am trying to develop an application which requires me to send data to a HTML webpage - http://patft.uspto.gov/netahtml/PTO/search-bool.html and the user...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.