473,508 Members | 2,032 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

About Insert Into query using where clause

9 New Member
I am using access connection like-
Expand|Select|Wrap|Line Numbers
  1. a = TextBox2.Text.Remove(1)
  2.         a = TextBox2.Text.Remove(1)
  3.         c = TextBox3.Text.Remove(1)
  4.         b = TextBox4.Text
  5.         TextBox5.Text = a + c + " " + b
  6.         Dim com As New OleDbCommand("INSERT INTO Employees(Code) VALUES(@cd) WHERE Sr_No='" & TextBox1.Text & "'", Connect.OledbConnection())
  7.         com.Parameters.AddWithValue("@cd", TextBox5.Text)
  8.         com.Connection.Open()
  9.         com.ExecuteNonQuery()
  10.         com.Connection.Close()
  11.         MsgBox("OK")
  12.         'Catch ex As Exception
  13.         ' MsgBox(ex.Message)
  14.         'End Try
but there is a problem inwhere clause it is giving me error as "Missing semicolon (;) in SQL statement...
Is there any solution for that ?
Mar 13 '08 #1
2 2472
QVeen72
1,445 Recognized Expert Top Contributor
Hi,

You will get the error if any of the Textboxes have a Single or Double Quote..
' Or "

Before updation you have to check, and remove those chars..

REgards
Veena
Mar 13 '08 #2
debasisdas
8,127 Recognized Expert Expert
Why using where clause in insert into statement ?

Either remove the where clause of use Update statemnet.
Mar 13 '08 #3

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

Similar topics

1
3029
by: Steve | last post by:
I've run in to a problem with a query I'm trying to write. I have attached a sample SQL script at the end of this post to show an overview of what I'm working with. I want to be able to use...
18
10248
by: Robin Lawrie | last post by:
Hi again, another problem! I've moved from an Access database to SQL server and am now having trouble inserting dates and times into seperate fields. I'm using ASP and the code below to get the...
3
5752
by: Magnus Byne | last post by:
Hi, I have a problem using serializable transactions. In one transaction I select a single specific row from a table using a where clause (this causes it to acquire and hold a range lock). In...
16
16975
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
52069
by: maltchev | last post by:
i need to insert data from an xml file into sql server table. the xml file contains only one record. how to insert the data? how to map the names of the fields in the xml file and the table?...
3
14671
by: Ian Bell | last post by:
Hi All I have just upgraded to SQL2005 and found an annoying problem. Whenever I add a new view or amend an existing one (created in SQL 2000 Enterprise Manager) it inserts TOP 100 Percent into...
24
19861
by: clare at snyder.on.ca | last post by:
I have a SQL query I need to design to select name and email addresses for policies that are due and not renewed in a given time period. The problem is, the database keeps the information for every...
3
2147
by: Mike Charney | last post by:
I have a two part question: First I want to insert data into a table and I am using the following command: INSERT INTO tblmain SELECT field1, field2, etc... FROM tblimport WHERE ?????? The...
10
1620
by: Steve Kelley | last post by:
Hello all. I'm new to this group and I'm working on my first real VB.Net project. I'm having trouble creating and archive of a database. We use an Access database to store results from our...
0
7127
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
7331
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
7391
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...
1
7054
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...
0
7501
tracyyun
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...
0
5633
agi2029
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,...
0
4713
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...
0
3204
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...
0
3188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.