Solved

Insert and update records using a DB Navigator in Delphi

Posted on 2008-06-23
5
2,293 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
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 synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

734 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