Solved

Insert and update records using a DB Navigator in Delphi

Posted on 2008-06-23
5
2,204 Views
Last Modified: 2013-11-23
I am looking for a db navigator to insert and update a Microsoft sql 2000 database using an ado query.

I have a dbnavigator on a form but eventually I want to use it on numerous forms in an application. I want the form to be locked until a user presses the edit/insert button on the navigator and then once this occurs the dbnavigator then only displays the post /cancel buttons. If the cancel button is pressed then no changes are made but if the post button is pressed then the database gets populated.

My table is called customers and has the following fields:

customer_link  int  4  no null
customername  nvarchar  50  no null
customerref  nvarchar  50  no null
website  nvarchar  50 allow null

I have tried to get the insert query to work but I have problems inserting a unique identifier into the field customer_link and I am struggling with the update query.

Thanks
0
Comment
Question by:ubernewb
  • 3
  • 2
5 Comments
 
LVL 10

Expert Comment

by:dinilud
ID: 21852650
0
 
LVL 10

Expert Comment

by:dinilud
ID: 21852655
set 'customer_link' as autoincement field
0
 

Author Comment

by:ubernewb
ID: 21852904
Hi dinilud,

It kind of answers the question about inserting new values into the sql table but not really on the update, any suggestions?
0
 
LVL 10

Accepted Solution

by:
dinilud earned 500 total points
ID: 21853878
Insert (Assume customer_link is autoinc field)
=====
   INSERT INTO tbl (customername,customerref,website)
                Values('xxxxx','yyyyy','zzzzz')    //automatically added customer_link
   customer_link= Get Last Insered ID; //In MySQL 'SELECT LAST_INSERT_ID()'

Update
=======
   UPDATE tbl SET customername='xxxx1',customerref='yyyy1',website='zzzz1'
         WHERE customer_link=10

In my program, i managed like this. I don't know whether there is any problem.

Any way wait for other Experts.
0
 

Author Closing Comment

by:ubernewb
ID: 31469999
Thanks for your help
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now