Solved

Insert and update records using a DB Navigator in Delphi

Posted on 2008-06-23
5
2,317 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
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 keystrokes in Netbeans IDE 8.0 for Windows.

688 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