473,666 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

error missing(;) at the end of sql statement

1 New Member
I m writhing the code as below in the button click event:

Dim count As String = "select max(CutomerId) from CustomerInfo"
cn.Open()
cmd = New OleDbCommand(co unt, cn)
Dim max1 As String = cmd.ExecuteScal ar()
max = Convert.ToInt32 (max1)
cn.Close()
cn.Open()
Dim im As String = "insert into CustomerInfo(Ad dress1,Address2 ,Email,PassPort No) values('" & txtadd1.Text & "','" & txtadd2.Text & "','" & txtemail.Text & "','" & txtpno.Text & "') where CutomerId= " & max.ToString()
cmd = New OleDbCommand(im , cn)
cmd.ExecuteNonQ uery()
cn.Close()

On execution of the code i m getting the error
Missing semicolon (;) at end of SQL statement
could u pls help me to get rid of this error
Note i m using ms-access as my database
Oct 4 '07 #1
1 1582
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
I m writhing the code as below in the button click event:

Dim count As String = "select max(CutomerId) from CustomerInfo"
cn.Open()
cmd = New OleDbCommand(co unt, cn)
Dim max1 As String = cmd.ExecuteScal ar()
max = Convert.ToInt32 (max1)
cn.Close()
cn.Open()
Dim im As String = "insert into CustomerInfo(Ad dress1,Address2 ,Email,PassPort No) values('" & txtadd1.Text & "','" & txtadd2.Text & "','" & txtemail.Text & "','" & txtpno.Text & "') where CutomerId= " & max.ToString()
cmd = New OleDbCommand(im , cn)
cmd.ExecuteNonQ uery()
cn.Close()

On execution of the code i m getting the error
Missing semicolon (;) at end of SQL statement
could u pls help me to get rid of this error
Note i m using ms-access as my database
Expand|Select|Wrap|Line Numbers
  1. Dim count As String = "select max(CutomerId) from CustomerInfo"
  2. cn.Open()
  3. cmd = New OleDbCommand(count, cn)
  4. Dim max1 As String = cmd.ExecuteScalar()
  5. max = Convert.ToInt32(max1)
  6. cn.Close()
  7. cn.Open()
  8. Dim im As String = "insert into CustomerInfo(Address1,Address2,Email,PassPortNo) values('" & txtadd1.Text & "','" & txtadd2.Text & "','" & txtemail.Text & "','" & txtpno.Text & "') where CutomerId= " & max.ToString() & ";"
  9. cmd = New OleDbCommand(im, cn)
  10. cmd.ExecuteNonQuery()
  11. cn.Close()
Does this help?
ding ding!
You need to put a ';' at the end of the sql statement :)

cheers
Oct 4 '07 #2

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

Similar topics

7
2190
by: BWGames | last post by:
Can someone tell me whats up with this code please? $update_query = "UPDATE users SET creditremaining = creditremaining - " . $_REQUEST . "WHERE mobilenumber = " . $_REQUEST . ""; where creditremaining is a MySQL table field, and $_REQUEST is a HTTP GET variable. Thanks,
3
6223
by: Robert Mark Bram | last post by:
Hi All! I have the following two methods in an asp/jscript page - my problem is that without the update statement there is no error, but with the update statement I get the following error: Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80004005) Syntax error in UPDATE statement. /polyprint/dataEntry.asp, line 158
29
2477
by: shank | last post by:
1) I'm getting this error: Syntax error (missing operator) in query expression on the below statement. Can I get some advice. 2) I searched ASPFAQ and came up blank. Where can find the "rules" for when and how to use single quotes and double quotes in ASP? thanks! ---------------------- SQL = SQL & "WHERE '" & REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE("GenKTitles.
6
4739
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much appreciated. Thanks in advance
102
5649
by: Skybuck Flying | last post by:
Sometime ago on the comp.lang.c, I saw a teacher's post asking why C compilers produce so many error messages as soon as a closing bracket is missing. The response was simply because the compiler can't tell where a bracket is missing.... a few weeks have past, I requested a feature for the delphi ide/editor "automatic identation of code in begin/end statements etc" and today when I woke up I suddenly released a very simple solution for this...
2
5731
by: Qiao Yun | last post by:
I used vc++.net (visual studio .net ) to open a project which can work well in vc++6.0. I succeeded in compiling the project in vc++.net in release mode . But when I tried to compile the project in debug mode, the following errors happened: d:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xdebug(29): error C2365: 'new' : redefinition; previous definition was a 'member function' d:\Program Files\Microsoft Visual Studio...
2
9448
by: Charles Wilt | last post by:
I have a IBM iSeries (aka AS-400) running v5r3 of OS/400 that I access via a linked server from SQL Server 2000. The following select works fine: select * from prod400db.test.meldbf.InventoryHistory However, this insert statement fails: insert into prod400db.TEST.MELDBF.InventoryHistory
2
11307
by: martin-g | last post by:
Hi. When the user opens the Excel file, which is at the same time used by my application, it stops calculations and throws an exception with such information: "The object invoked has disconnected from its clients". What can I do to resolve this? My application opens the source excel file using this statement: oRatelistWbk = AppExcel.Workbooks.Open( m_FilePath, Missing.Value, true, Missing.Value, Missing.Value,
5
6099
by: elie.constantine | last post by:
Hello A person developed a Microsoft Access Solution and gave me the MDE file. When I tried to run it, I got "Function is not available in expressions in query expression 'Trim([......" Error. I learnt from the Microsoft Website and from this Group that this is problem is the result of a mismatch between the Computer where this database was developed and compiled on and the Computer where I am trying to run it.
25
3982
by: notahipee | last post by:
I have been trying to cin an number from 0 to 9 with a leading 0. For example 00 or 07. I was using a switch case. switch (int) { case 01: break; case 02: break;..... My problem arises at 08 and 09 because they are not octal. Is there any way to coerce the input variable to decimal despite it having a leading zero .
0
8444
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8869
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, 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...
1
8551
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,...
1
6198
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5664
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();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4368
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2771
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 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.