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

error missing(;) at the end of sql statement

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(count, cn)
Dim max1 As String = cmd.ExecuteScalar()
max = Convert.ToInt32(max1)
cn.Close()
cn.Open()
Dim im As String = "insert into CustomerInfo(Address1,Address2,Email,PassPortNo) values('" & txtadd1.Text & "','" & txtadd2.Text & "','" & txtemail.Text & "','" & txtpno.Text & "') where CutomerId= " & max.ToString()
cmd = New OleDbCommand(im, cn)
cmd.ExecuteNonQuery()
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 1567
Shashi Sadasivan
1,435 Expert 1GB
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(count, cn)
Dim max1 As String = cmd.ExecuteScalar()
max = Convert.ToInt32(max1)
cn.Close()
cn.Open()
Dim im As String = "insert into CustomerInfo(Address1,Address2,Email,PassPortNo) values('" & txtadd1.Text & "','" & txtadd2.Text & "','" & txtemail.Text & "','" & txtpno.Text & "') where CutomerId= " & max.ToString()
cmd = New OleDbCommand(im, cn)
cmd.ExecuteNonQuery()
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
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...
3
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: ...
29
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"...
6
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...
102
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...
2
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...
2
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...
2
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...
5
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. ...
25
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...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.