Thursday, February 16, 2012

Adding data to database with other application not SQL

Hi,
I have a database that it have and int type with identity (1,1).when I add
data from sql everything is ok but when I want to add data from fro example
Delphi it says that field ID must have a value and auto numbering doesn't
work.
Please tell me how can I solve my problem.
Regards
Ali"Ali.M" <AliM@.discussions.microsoft.com> wrote in message
news:4D01366E-E296-4C7E-84FF-58EA93329088@.microsoft.com...
> Hi,
> I have a database that it have and int type with identity (1,1).when I add
> data from sql everything is ok but when I want to add data from fro
example
> Delphi it says that field ID must have a value and auto numbering doesn't
> work.
> Please tell me how can I solve my problem.
> Regards
> Ali
It sounds to me like Delphi is trying to be helpful and wants to generate a
value for each column that you pass in. If that is the case and you are
picking a table to update from Delphi, you may try creating a View in SQL
Server for the table that leaves off the Identity column. Point Delphi at
the View instead and see if that doesn't solve your problem.
Example:
CREATE TABLE Foo (
IDCol int IDENTITY(1, 1) NOT NULL,
FirstName varchar(20) NULL,
LastName varchar(20) NOT NULL
SSN varchar(9) NOT NULL
)
CREATE VIEW vFoo AS
SELECT FirstName, LastName, SSN FROM Foo
Rick Sawtell
MCT, MCSD, MCDBA|||Instead of accessing your tables from applications directly, make it a
standard practice to use stored procedures.
When in doubt search for 'procedure' in this newsgroup. And of course Books
Online will provide lots of help.
ML

No comments:

Post a Comment