473,597 Members | 2,239 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SQL string can't update database

1 New Member

"," & _
"'" & Request.Form("u sername") & "'," & _

Conn.Execute SQL

This generates an error because my first field in the table (line 2 in the sql statement) is an AutoNumber and I don't know how to skip adding values to that field.

The above code gives me
Syntax error in INSERT INTO statement.

If I put a 0 in the first field before the comma I get ...
The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again.

Just to test it, I tried ...
Sql="insert into Players (username) values('" & Request.Form("u sername") & "'" )
I get

Error: Missing Fields
You must enter all fields to proceed.
Dec 9 '06 #1
3 1850
692 Recognized Expert Contributor
Give sql like this

"'" & Request.Form("u sername") & "'," & _

don't put anything for the autonumber field.

Dec 12 '06 #2
21 New Member
I have another field, cID which is a Primary Key AUTO_NUMBER. I skip it and the DB takes care of it.

Expand|Select|Wrap|Line Numbers
  1. SQL = "INSERT INTO class (cName,cShow) VALUES('"
  2.             SQL = SQL & cName & "','" & cShow & "');"
  3.             'response.Write(sql)
  4.             'response.End()
  5.             'Open connection
  6.             'objConn.open
  7.             objConn.Execute SQL
  9.             closeConn()
Dec 12 '06 #3
7 New Member
I have another field, cID which is a Primary Key AUTO_NUMBER. I skip it and the DB takes care of it.

Expand|Select|Wrap|Line Numbers
  1. SQL = "INSERT INTO class (cName,cShow) VALUES('"
  2.             SQL = SQL & cName & "','" & cShow & "');"
  3.             'response.Write(sql)
  4.             'response.End()
  5.             'Open connection
  6.             'objConn.open
  7.             objConn.Execute SQL
  9.             closeConn()
if cID is sequential field defined by DBMS, i think u shouldn't type it in INSERT query. If i was you I would do this

"INSERT INTO class (cShow) VALUES("& _
" ' "& cShow & "');"
'response.Write (sql)
'Open connection
objConn.Execute SQL


I think that'll work properly
Dec 12 '06 #4

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

Similar topics

by: wqhdebian | last post by:
As far as I know,when encrypt or decrypt ,a key must first be got,and the key is first generate by a tool or from SecurityRandom,that means I can not generate the same key with the same input.Does there is a method which can generate a same with the same input string? There is a need to transfer file between to site,and the customer wish to encrypt these files during transfering,and they want to store a string into each database at...
by: Qwiati | last post by:
Hi My user has put ' with editable place and then press enter so this same way put text information with ' string into database. When I try tu user command : UPDATE and try to change text with ' and use command WHERE = ('text'') then I just received error command from SQL2000 server - I know what kind of problem is but i need your hel to get some diferent command or method to change wrong put information Thx for your qiuck help Kayser
by: Fred Zuckerman | last post by:
Hello All, After reading in this group about the preference for connecting to a SQL Server using a connection string instead of a DSN file, I have done just that. BUT, I cannot update my data. I have gone back and forth between using a DSN file and a DSN-less connection string and I have found the following issue. When I utilize the DSN file to create the link, there is a step where it asks me to identify a unique key for the file. If I...
by: bardo | last post by:
I have a question about the OleDBCommand. I am making a program that needs to load 6 tabels from a Access DataBase. At the moment I got everything working by making 6 Adapters, CommandBuilders and using 6 times the Adapter.fill() command. I would like to know if there is a way to bring it back to 1 Adapter command. Right know the code looks like this. (I only put 2 Adapter Commands cause the rest is the same)
by: Ottar | last post by:
I have a few numeric fields, and when I update i get the error: "Input string was not in a correct format". Next line:" System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +2178925" This is beacuse some of my TextBoxes are empty (no value). If I enter a value it is OK. I need to use Null values to indicate that the field is not fileld in.
by: Manuel Canas | last post by:
Hello there, this is the piece of code that if giving problems right now; cnSQL = New SqlConnection(ConnectionString) **** strSQL = "UPDATE tb_product SET (ProductID = @cProductID, Code = @Code, ServiceName = @ServiceName, Price = @Price " & _ "WHERE ProductID = @cProductID)" ****
by: BenG | last post by:
Hi. I have a gridview control on a web form (asp.net 2.0) that's bound to a objectDataSource. The objectdatasource which is bound to a class I've written in the DAL to read and update the database. The grid contains three columns - an ID (GUID), a name (string) and a rowversion (timestamp), and the data is passed to/from the page in an instance of a data entity object. When I open the page the grid loads properly, but if I attempt to edit...
by: csrocker101 | last post by:
Ok basically I've got two programs. A client and a server application. In the client you can either send one string with just use the username which will tell the server not to update the database or two strings which has a space in between them which will inform the server to update the database. Bascially both strings regardless if there is a space or not are excepted by my server application as just one string. In my server I am trying to...
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi all, I have a "connected" datagridview that uses a bindingsource/datatable to load the grid and update the user's modifications to the database. I have a column that is set in the database as varchar, but it is populated with values ranging from 1 to 49. It is not an option to change the column to integer in the database. When I sort the column by clicking on the column header it sorts alphabetically as expected (Ex. 1, 10, 11,...
by: andrei.avk | last post by:
Hi, I'd like to store chunks of text, some of them may be very large, in a database, and have them searchable using 'LIKE %something%' construct. These pieces of text may have single and double quotes in them, I tried escaping them using re module and string module and either I did something wrong, or they escape either single quotes or double quotes, not both of these. So that when I insert that text into a db record, this causes an error...
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...
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,...
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: 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...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.