here is my code. dont seem to know whats the problem. i have 12 data fields in access excluding the ID field. - Dim strCon As String = "Provider=Microsoft.jet.oledb.4.0;data source=C:\Users\dexter\Documents\desktop\csci14\database\Museum-final.mdb"
-
Dim dSet As New DataSet
-
Dim M_I As String
-
Dim Fname As String
-
Dim Lname As String
-
Dim Age As Integer
-
Dim Address As String
-
Dim Email As String
-
Dim Tel_Cell As String
-
Dim status As String
-
Dim Bill As Integer
-
Dim Nat As String
-
Dim Vis_no As Integer
-
Dim DoV As String
-
-
M_I = M_ITextBox.Text
-
Fname = FirstNameTextBox.Text
-
Lname = LastNameTextBox.Text
-
Age = Val(AgeTextBox.Text)
-
Address = AddressTextBox.Text
-
Email = EmailTextBox.Text
-
Tel_Cell = Tel_CellTextBox.Text
-
status = StatusTextBox.Text
-
Bill = Val(BillTextBox.Text)
-
Nat = NationalityTextBox.Text
-
Vis_no = Val(Visitor_NoTextBox.Text)
-
DoV = DateTimePicker1.Text
-
-
Try
-
cn = New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;data source=C:\Users\dexter\Documents\Visual Studio 2010\Projects\Admission_form\Admission_form\Museum-final.mdb")
-
-
cmd = New OleDbCommand("select * FROM Visitor", cn)
-
cmd.CommandText = ("INSERT into Visitor ([Visitor_No],[FirstName],[M_I],[LastName],[Address],[Age],[email],[Tel/Cell],[Status],[Bill],[Nationality],[DateOfVisit]) values(" & Vis_no & "," & Fname & "," & M_I & "," & Lname & "," & Address & "," & Age & "," & Email & "," & Tel_Cell & "," & status & "," & Bill & "," & Nat & "," & DoV & ")")
-
cn.Open()
-
cmd.ExecuteNonQuery()
-
clearTxtBox()
-
-
cn.Close()
-
cn.Dispose()
-
Catch ex As System.Exception
-
MsgBox(ex.Message, MsgBoxStyle.Critical, "General Error")
-
End Try
-
3 5621
At line 33 in the VALUES part of your statement you will need to enclose each and every text value in single quotes, like this: - values(" & Vis_no & ", '" & Fname & "','" & M_I & "','" & Lname & "','" & Address & "'," & Age & ",'" & Email & "','" & Tel_Cell & "','" & status & "'," & Bill & ",'" & Nat & "'," & DoV & ")")
Values inserted as string literals MUST be delimited by single quotes on either side of the literal value. I've shown examples of how to do this above, but I might not have caught them all so you'll have to make sure that you do so. Numeric values do not need delimiting, but please be aware that telephone numbers are stored as text strings so they require delimiting, as shown above.
-Stewart
hello. tnx for your reply. i tried it but still got an error: - Syntax error (missing operator)in query expression
-
",0,'dex','bvn,",",0,",",",0,",'Monday'.
ive entered "dex" in FirstnameTexbox and bvn in M_Itextbox.the monday appears bcos ive set the value of DateOvtextbox to the value of the datetimepicker1 and set it to text as to my code above"
I added code tags to the error message you quoted above to make the characters shown clearer. If you look at the 'bvn value you will see that it is missing its closing single quote.
As I said in my first reply, values must be enclosed by single quotes, and this one clearly is not.
There also appear to be various double quotes orphaned later in your string, and the example use of single-quotes which I provided would not have resulted in the orphaned double quotes you show in the error statement.
Please bear in mind that in building the SQL statement the parts within double quotes belong to the SQL string itself. The single quotes delimit string literal values supplied from your controls or variables. These delimiters are within the double-quoted string sections, and typically start after the comma for the previous field, and end before the comma for the one after that, like this - "VALUES(" & var1 & ", '" & var2 & "', '" & var3 & "')"
You must make sure that you have a SQL string which is entirely correct in format. You may have to break it down further so that you can be certain that each part of the substring is correctly formed.
-Stewart
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Gert Jan Wiersema |
last post by:
Hello all,
I'm trying to give users a form in which they can check all 52 weeks
of the year. This is done in a $weeks_array thingy. Unfortunately
it seems that only 46 of the 52 values (and some other hidden values
such as username etc) make it to the next page ($n 0-45). Is there a
limit of values in forms?
thanx,
gert
|
by: Mike |
last post by:
My users have to select an value from a fixed selection of values. The
obvious choice of control for such a requirement is to use a <select> (i.e.
a combo box).
My problem is that sometimes, these combo boxes will have a *large* number
of values. There could be any number of values in them from 5 to 5 million
(unlikely it would be this large but possible).
Obviously 5 million is far too much to populate a <select> control with.
Does...
|
by: Zb Bornemann |
last post by:
Hi All,
Ok. Here's what my table looks like:
Field1 Field2 Field3 Field4...
Record1 1 3 2 9
Record2 9 1 9 4
Record3 1 3 1 2 etc, etc.
What I want to do is for each record, count the number of values across the
|
by: ralamo |
last post by:
When i execute the following insert query, the above mentioned error
is coming. Anything wrong in the query?
INSERT INTO ECN_1 (Old_SbPartNo, Old_PartDesc, Old_ManPartNo,
Old_Manuf, Old_Vendor, Old_RefDesi, Old_Qty,
New_SbPartNo, New_PartDesc, New_ManPartNo,New_Manuf, New_Vendor,
New_RefDesi, New_Qty)
select * from (select SB0014.SbPartNo, SB0014.partDesc,
SB0014.mANpARTnO, SB0014.manufacturer,
|
by: kathyburke40 |
last post by:
Odd problem. I have a table in the following format:
DocID Question1 Question2 Question3
------------------------------------------------
298 1, 2, 3 or 0
Each Question field will have 1,2,3 or 0 if not completed. The number
of Question fields will vary.
I need to count all the questions, then figure out how many have 0
| |
by: yxktmp |
last post by:
Hi;
I have a main starting query for most of my reporting. I branch out from this query to other queries. This main query contains multiple form control filters (query criterias) . I want to use this query from multiple forms because each report needs different filters on this query. Is there a way to to this like having multiple copies of this query keeping the name same, like an alias name? I would appreciate ideas on this. Thanks!
...
|
by: Kosmos |
last post by:
I'm getting this error message: Number of query values and destination fields are not the same.
This is the code:
INSERT INTO tblDateDifference ( DateDifference )
SELECT tblContracts.EndDate As EndDate,
IIf( > EndDate, DaysToCompletion(EndDate), DaysCompleted(EndDate)) AS DateDifference,
FROM tblContracts;
Can someone please tell me why I'm getting this error message? PLEASE?!?! lol
|
by: R Bandeira |
last post by:
How to keep values in fields after ChangeMode to Insert from Edit? I
am implementing a re-insert type feature, after an edit.
// Change form to insert mode
FormView1.ChangeMode(FormViewMode.Insert);
// Repopulate the form
Label.Text = "12345";
TextBox.Text = "22";
|
by: cypriot |
last post by:
Hi. I am developing an application program in java. I use MsAccess for keeping data.
I had a problem with sql insert method.
public void AddPatient()
{
String no= numberinput.getText();
|
by: monion |
last post by:
One more question.
How can I get query values assign them to a variable, but not show them?
for example size, $f4 in the following: How can I pass that value $f4 to the form handle page to submit to the database. I can clearly see how to pass $f2 with quantity stuck on the end.
Basically, I need to pass 3 things: 1) item#, 2) item#quantity and 3) size to a new database.
mysql_select_db("inventory");
$query="SELECT * FROM...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |