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

Problems with INSERT statement sent to Access

hi pls someone help me whit this i need to fill a table from visual basic but i try at least every code that have in the net pls someone pls help this is the last code that i imput

Expand|Select|Wrap|Line Numbers
  1. Dim sql As String
  2. Dim mycon As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  3.     "Data Source = gigtoyo.mdb"
  4. Dim dt As New DataTable
  5. sql = "INSERT INTO invoice(invoice, fechatrans, descripcion, nombre, " _
  6.     & modelo, pronto, casafina, fina, total)VALUES(" _
  7.     & TextBox9.Text & ", #" & DateTimePicker1.Text & "#, '" _
  8.     & TextBox3.Text & "', '" & TextBox1.Text & "', '" & TextBox2.Text _
  9.     & "', '" & TextBox7.Text & "', " & TextBox6.Text & ", " _
  10.     & TextBox8.Text & ", " & TextBox4.Text & ")"
  11. Dim sqlexe As New OleDb.OleDbDataAdapter(sql, mycon)
  12. sqlexe.Fill(dt)
  13. sqlexe.Dispose()
May 6 '07 #1
3 1739
Dököll
2,364 Expert 2GB
hi pls someone help me whit this i need to fill a table from visual basic but i try at least every code that have in the net pls someone pls help this is the last code that i imput
Expand|Select|Wrap|Line Numbers
  1.  
  2.         Dim sql As String
  3.         Dim mycon As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source = gigtoyo.mdb"
  4.         Dim dt As New DataTable
  5.         sql = "INSERT INTO invoice(invoice, fechatrans, descripcion, nombre, modelo, pronto, casafina, fina, total)VALUES(" & TextBox9.Text & ", #" & DateTimePicker1.Text & "#, '" & TextBox3.Text & "', '" & TextBox1.Text & "', '" & TextBox2.Text & "', '" & TextBox7.Text & "', " & TextBox6.Text & ", " & TextBox8.Text & ", " & TextBox4.Text & ")"
  6.         Dim sqlexe As New OleDb.OleDbDataAdapter(sql, mycon)
  7.         sqlexe.Fill(dt)
  8.         sqlexe.Dispose()
Expand|Select|Wrap|Line Numbers
  1.  
  2.  
Hello, omi1800!

You are missing single quotes in your VALUES command:

('" & TextBox9.Text & "', and others within the same command

You now have (" & TextBox9.Text & ",

Also, I do not think #" & DateTimePicker1.Text & "#, will work, try getting rid of the # sign there, add single quotes run it again.

Good luck with the project!

Dököll
May 7 '07 #2
Killer42
8,435 Expert 8TB
...
Also, I do not think #" & DateTimePicker1.Text & "#, will work, try getting rid of the # sign there, add single quotes run it again.
If the field type is Date/Time, then I'm fairly certain you do need the # delimiters. However, you should force the date into U.S. format (mm/dd/yyyy). Alternatively, I think you can probably get away with a format which can't be easily confused, such as one with the month in text (Eg. #7 May 2007#).

By the way omi1800, you didn't say what the problem is, or what version of VB you're using.
May 7 '07 #3
Dököll
2,364 Expert 2GB
Ahhh! I was reminded of a query in VB 6, please carry on...Thanks.
May 8 '07 #4

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

Similar topics

11
by: Markku Uttula | last post by:
I think I'm doing something wrong. I'm able to connect to Oracle just fine, execute queries and all, but I'm having serious problems with the speed :( For example, the following PHP-script on my...
6
by: CJM | last post by:
I've created a Stored Procedure which adds a new record and updates some more records and then returns the primary key for the added record. The SP seems to work OK, but I'm having problems...
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
2
by: JMCN | last post by:
i am running into problems with is the recordset. i have exactly 104 records. when i tested the code, the end result was multiple records for the same loan(ET LN Shortname). where did i go wrong? ...
6
by: Kathy Burke | last post by:
Ugh. I'm using the following in an asp.net. I get an Syntax Error in INSERT INTO Statement on line Cmd1.ExecuteNonQuery(). I've made all my database fields text (just to eliminate that as a...
4
by: Mike Hnatt | last post by:
My goal is to get data from an XML file into a couple of tables in an Access database. The XML file is a little complex so I need control over what I do (I can't just read it into a dataset). ...
1
by: glenn | last post by:
Hi folks, I am using an Access database, VB.NET and ADO.NET working with a DataGrid control. MY datagrid table has both a date_sent and a date_ans field. When I Insert a record in my SQL...
5
by: Brad Baker | last post by:
I'm trying to write a simple asp.net page which updates some data in a SQL database. At the top of the page I have the following code: <%@ Page Language="C#" Debug="true" %> <%@ import...
3
by: Greg Corradini | last post by:
Hello, I'm trying to perform a simple insert statement into a table called Parcel_Test (see code below). Yet, I get an error message that I've never seen before (see traceback below). I've tried...
13
by: Terry Olsen | last post by:
I'm using OleDb to connect with an Access Database. I have anywhere from 10 to over 100 records that I need to either INSERT if the PK doesn't exist or UPDATE if the PK does exist, all in a single...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.