Several Delphi ADO Database help questions

Okay, I have an Access database connected to an ADO dbgrid in delphi through ADO connections. there are a few problems I'm having with it.

Firstly, I have a lookup table for one of my columns set up in access, it's for a supplierID column, it gets the supplier ID number and the supplier name from a suppliers table for you to select from. This doesn't work in the delphi DBGrid, I have looked for ways to allow it to display but all I've found are complex blocks of code that don't work for me and that I don't have the skill to adapt.

Secondly, I have several buttons for manipulating the data such as delete, append, edit etc. However, these functions can all be done by just double clicking on the dbgrid and then editing it. is there any way I can block this from being done without using the buttons?

Thirdly, though this is less major, when in the program a user attempts to add a record without required fields entered, there is an automatic error given, is there any way I can change this error?

Thanks in advance for your help, if there's any other information you need, I'll be happy to give it to you.
0
Phil
4/8/2009 4:28:25 PM
embarcadero.delphi.ado 597 articles. 1 followers. Follow

6 Replies
904 Views

Similar Articles

[PageSpeed] 5

> {quote:title=Phil Jonestone wrote:}{quote}
> Secondly, I have several buttons for manipulating the data such as delete, append, edit etc. However, these functions can all be done by just double clicking on the dbgrid and then editing it. is there any way I can block this from being done without using the buttons?

Set dgEditing to False on the Options property of TDBGrid.

regards

/Micke
0
Mikael
4/8/2009 5:11:13 PM
> {quote:title=Phil Jonestone wrote:}{quote}
> Thirdly, though this is less major, when in the program a user attempts to add a record without required fields entered, there is an automatic error given, is there any way I can change this error?
 
In the OnPostError event on TADODataSet you can show whatever error message you like and then set Action := daAbort.

regards

/Micke
0
Mikael
4/8/2009 5:18:42 PM
> {quote:title=Mikael Eriksson wrote:}{quote}
> > {quote:title=Phil Jonestone wrote:}{quote}
> > Thirdly, though this is less major, when in the program a user attempts to add a record without required fields entered, there is an automatic error given, is there any way I can change this error?
>  
> In the OnPostError event on TADODataSet you can show whatever error message you like and then set Action := daAbort.
> 
> regards
> 
> /Micke

Thanks a lot for all your help.

So, what sort of if statement would I need to include there? Is there a simple way to get the contents of the particular column and put it into an if blah=''
then showmessage('blah')

kind of thing?

Sorry if this should all be obvious, I'm a real beginner.
0
Phil
4/8/2009 5:48:12 PM
Phil Jonestone wrote:
>> {quote:title=Mikael Eriksson wrote:}{quote}
>>> {quote:title=Phil Jonestone wrote:}{quote} Thirdly, though this
>>> is less major, when in the program a user attempts to add a
>>> record without required fields entered, there is an automatic
>>> error given, is there any way I can change this error?
>> 
>> In the OnPostError event on TADODataSet you can show whatever error
>> message you like and then set Action := daAbort.
>> 
>> regards
>> 
>> /Micke
> 
> Thanks a lot for all your help.
> 
> So, what sort of if statement would I need to include there? Is there
> a simple way to get the contents of the particular column and put it
> into an if blah='' then showmessage('blah') kind of thing?
> 
> Sorry if this should all be obvious, I'm a real beginner.

if TableCustomer['FirstName']='' then begin
   ShowMessage('First name must be entered!');
   Abort;
end
else if TableCustomer['LastName']='ObviousBadName' then begin
   if MessageDlg('Are you sure you want the last name to be'
    '+TableCustomer['LastName']+'?',mtConfirmation,[mbYes,mbNo],0)=mrNo
    then Abort;
end
else if ....
end;

-- 
Jon Purvis
Wildlife Data Analyst
Texas Parks and Wildlife Department
Austin, TX
0
Jon
4/8/2009 7:01:45 PM
> {quote:title=Jon Purvis wrote:}{quote}
> Phil Jonestone wrote:
> >> {quote:title=Mikael Eriksson wrote:}{quote}
> >>> {quote:title=Phil Jonestone wrote:}{quote} Thirdly, though this
> >>> is less major, when in the program a user attempts to add a
> >>> record without required fields entered, there is an automatic
> >>> error given, is there any way I can change this error?
> >> 
> >> In the OnPostError event on TADODataSet you can show whatever error
> >> message you like and then set Action := daAbort.
> >> 
> >> regards
> >> 
> >> /Micke
> > 
> > Thanks a lot for all your help.
> > 
> > So, what sort of if statement would I need to include there? Is there
> > a simple way to get the contents of the particular column and put it
> > into an if blah='' then showmessage('blah') kind of thing?
> > 
> > Sorry if this should all be obvious, I'm a real beginner.
> 
> if TableCustomer['FirstName']='' then begin
>    ShowMessage('First name must be entered!');
>    Abort;
> end
> else if TableCustomer['LastName']='ObviousBadName' then begin
>    if MessageDlg('Are you sure you want the last name to be'
>     '+TableCustomer['LastName']+'?',mtConfirmation,[mbYes,mbNo],0)=mrNo
>     then Abort;
> end
> else if ....
> end;
> 
> -- 
> Jon Purvis
> Wildlife Data Analyst
> Texas Parks and Wildlife Department
> Austin, TX

I can't get that to work at all, maybe the way I'm connecting to the database is what's wrong.

I have an access database connected with ADO connection, db source and db table components.
0
Phil
4/13/2009 2:12:04 PM
> 
> Firstly, I have a lookup table for one of my columns set up in access, it's for a supplierID column, it gets the supplier ID number and the supplier name from a suppliers table for you to select from. This doesn't work in the delphi DBGrid, I have looked for ways to allow it to display but all I've found are complex blocks of code that don't work for me and that I don't have the skill to adapt.

Define persistant fields for your TadoDataset and add a lookup field to the Tfields.  The TdbGrid will handle the lookup when you include the lookup field in the grid
0
Brian
4/14/2009 1:51:37 AM
Reply:

Similar Artilces:

Convert Delphi 5 ADO App to Delphi 2007 ADO.NET
I have an appliction tha that is writen in Delphi 5 with ADOConnetion, ADOTable, and ADOQuery components. I need to upgrade to Delphi 2007 and use ADO.NET. I have the program building in with Delphi 2007. Is there anything I need to do to convert the ADO to ADO.NET? > I need to upgrade to Delphi 2007 and use ADO.NET. Why ? -- With best regards, Dmitry Arefiev AnyDAC (www.anydac.com) - Oracle, MS SQL Server, IBM DB2, MySQL, Firebird, Interbase, PostgreSQL, Sybase ASA, SQLite, MS Access, DBX, ODBC, InMem - universal high-speed native data access engine Reasons for change: - We already own the Delphi 2007. - We have existing product (code) what was created in Delphi 5. - We are wanting to update to the newer version and convert to the ADO.NET connection instead of the ADO. - I am being told to upgrade becuase ADO has issues with locking up machines and meno when used with SQL on very large datasets. Do you know what I need to do to convert the existing connections in ADO to ADO.NET? > {quote:title=Dmitry Arefiev wrote:}{quote} > > I need to upgrade to Delphi 2007 and use ADO.NET. > > Why ? > > -- > With best regards, > Dmitry Arefiev > AnyDAC (www.anydac.com) - Oracle, MS SQL Server, IBM DB2, MySQL, > Firebird, Interbase, PostgreSQL, Sybase ASA, SQLite, MS Access, DBX, > ODBC, InMem - universal high-speed native data access engine Unitime Development wrote: > I need to upgr...

Delphi 6 to Delphi 2010 upgrade and ADO
We have an application written in Delphi 6 Professional that uses ADO to access databases servers that may be on other PCs in our network. We want to move to Delphi 2010 but can't decide if we need Professional or Enterprise. 2010 Pro has dbGO - will this give us the same functionality as the ADO components we use in Delphi 6 Pro? Thanks, Keith > 2010 Pro has dbGO - will this give us the same functionality as the > ADO components we use in Delphi 6 Pro? Yes. > {quote:title=Joachim Uersfeld wrote:}{quote} > > 2010 Pro has dbGO - will this give us the same func...

ASA7 ADO & Delphi ADO ?? Anyone is using it?
Any comments? Is it working? Any Problems? Thanks Hi, PR <noemail@no.com> schrieb in im Newsbeitrag: BoTThJaq$GA.89@forums.sybase.com... > Any comments? Is it working? Any Problems? I tried to connect to ASA7 via the new OLE DB - Provider and ADOExpress from Delphi 5.01. No chance. Only the error message 'Invalid Enum Value'. About the new provider I haven't heard anything good until now... Regards Frank Frank, I've experienced the same problem with the ASA 7 OLEDB Provider. I'm not sure if this is a bug in the AsaProvider or Delp...

Help with ADO connectivity in Delphi XE
The company I work for has finally started migrating applications from Delphi 5 and 7 to Delphi XE and XE2. But, I am having a problem with a TADOConnection. A simple application built in D5 to connect to a MS SQL database works. But the same code compiled in Delphi XE will not connect. When the user's role changes from User to Power User, they can connect to the database in the app compiled in XE. The workstation that the user is running from is Windows XP. The SQL Server version is 2005. MDAC version 2.8 Unfortunately, we have been unable to simulate their environment, an...

Connection String for ADO Database in delphi prism
Hi, I want to connect to a database with ADO and aspx. from VB code what is the equivalent in delphi prism ? .... Dim MyReader as sqldatareader Dim MyConnection as sqlconnection = new sqlconnection() myConnection.connectionstring = configurationmanager.connectionstrings("DSN_MYDB").connectionstring Dim mycommand as sqlcommand = new sqlcommand() mycommand.commandtext="select * from mytable" mycommand.commandtype = commandtype.text mycommand.connection = myconnection mycommand.connection.open() Myreader=mycommand.executereader(commandbehavior.closeconnec...

ADO to ADO.NET help
Hi, I am converting application ASP to ASP.NET.What is the equivalent code in ADO.NET. For each F in RS.Fields FieldName = F.Name Next Thanks, Nate If it is forward only, then you can use datareader for more info on this, check below link Datareader on MSDN Hope it helps!Sreedharhttp://www.w3coder.orgweblog http://weblogs.asp.net/skoganti...

Help TeamSybase: Cannot use ASA with Delphi via ADO
Hello, I just installed ASA 60 days trial and I am testing with Delphi 6 and ADO, using TADODataset components. I am getting the following problems: when I post any record, trailing blanks are inserted in every TStringField (VARCHAR in ASA). When I post records with TMemoField or TBlobField (LONG VARCHAR), it raises a "Count field incorrect". I did't see this behaviour in other servers. Regards, Frank What are the version and build number of your server? Are you using the sample database or a database you created? If you created it, did you use the BLANK...

Compatability problem Windows7 and ADO database acces from Delphi XE
All, I don't know where i need to post this, so i thought i'd try here, if someone can tell me where i need to put this posting. I have an application written in Delphi XE which uses ADO database connectivity. It retrieves data from an IBM i (AS400) using SQL either directly or via user defined table functions on the server side. (Queries are run via TADOConnection, TADODataset and TADOQuery) The application runs 100% perfectly on Windows XP, but when i try to run the program on Windows7 i have the following issues: 32 Bit. All the UDTFs work correctly except one. This is not...

Help TeamSybase: Cannot use ASA with Delphi via ADO #2
Hello, I just installed ASA 60 days trial and I am testing with Delphi 6 and ADO, using TADODataset components. I am getting the following problems: when I post any record, trailing blanks are inserted in every TStringField (VARCHAR in ASA). When I post records with TMemoField or TBlobField (LONG VARCHAR), it raises a "Count field incorrect". I did't see this behaviour in other servers. Regards, Frank ...

Delphi and Delphi Prism licensing question
When I buy Delphi and Delphi Prism, do I get a "named user licence" or a "workstation licence"? Can I install both products on two machines I use with the same licence keys? I have a Mac Pro ("Cyrus") running Vista 64 in VMware and a MacBook ("Blacky") running Vista 32 in Parallels. Can I install Delphi and Delphi Prism on both Cyrus and Blacky since I use both machines (and like to have all dev tools I use installed on both machines at all times)? Andrew Brehm wrote: > When I buy Delphi and Delphi Prism, do I get a "named user licence...

Delphi 5 with ADO
Hi I'm having some problems adjusting a Delphi5/MSSQL database application, which i did not wrote (what's more: i'm not a Delphi expert either) so i thought maybe someone in this comunity will enlighten me. It' about an SQL command which is issued by this delphi5 application (the sql command was traced in SQL server with profiler), but which is nowhere to be found in the souce code. I've searched already all the components which i knew that could issue the SQL command (TADOQuery, TADOCommand) but with no l uck. Could anyone tell me other misterious places where i shou...

ASA7, ADO and Delphi
Hello! I've got a problem with accessing a database via ADO with Delphi 5. Everytime I set the ADOConnection active I get the error "Invalid enum value". I'm using Delphi 5 Enterprise and ASA7 with EBF #449. Is there anybody who ever get an ADOConnection to ASA7 with Delphi 5? Gruesse, Matthias I'm using C++ Builder 5 and get the same problem. I've asked this question before and no one seems to be able to respond... Matthias Hovestadt wrote: > Hello! > > I've got a problem with accessing a database via ADO > with Delp...

Question about Delphi 2009 vs Delphi 7
Hi, I was wondering if any of you can point me to a URLs that show the most important improvements between these versions of Delphi. The objective is convincing the powers-that-pay-the-bills that moving to D2009 (that we'd have to purchase) is a better idea than moving to D7 (for which we have licenses). Fire at will! -- Saluti, Alessandro Federici ------------------------------- "I have been through some terrible things in my life, some of which actually happened." (Mark Twain) Alessandro Federici wrote: > Hi, > I was wondering if any of yo...

System.ADO with Delphi debugger.
By 2 or 3 days Delphi debugger D7 , D9 and DXE stops with a System ADO fatal error (irretrievable error), when the program sets to True the ADOConnection's connected property. If the executable program run outside IDE the error does'nt raise, but when it starts inside IDE with debug option the error raise and the program stops and don't open the desired connection. I tried to repair MDAC on my system (Win32 XP SP3), but the problem remain. What can I do to use the debugger into IDE? (I use Delphi since 11 years and this problem never raised). Studio Rubabno Chairman wrote: &...

Delphi and Delphi for .Net
It seems that Delphi for .Net is slower than Delphi Win32 native applicaiton. I would like to know is it true all .Net application is slower than Win32 native applicaiton or it is Delphi for .Net only. Your information is great appreciated, Inung On 2011-06-21 18:20:17 +0100, Inung Huang said: > It seems that Delphi for .Net is slower than Delphi Win32 native applicaiton. > I would like to know is it true all .Net application is slower than > Win32 native applicaiton or it is Delphi for .Net only. If you are only running the code in the application once then, yes, yo...

ASA8 and Delphi ADO? Is it work?
Anybody test this configuration? As i can remember ASA7 don't work with Delphi via ADO. ---------------------------------- Oleg Kovalevsky Moscow, Russia I haven't tested ASA8 with Delphi, but I'm using ASA7 with Delphi 5 and ADOExpress. There are some glitches, but ASA support has been very helpful with addressing the problems. On Fri, 29 Mar 2002 17:01:05 +0300, "Oleg Kovalevsky" <okovalevsky@hotmail.com> wrote: >Anybody test this configuration? As i can remember ASA7 don't work with >Delphi via ADO. > > >----------...

Delphi, ADO, SQL Anywhere
This combination seem not to work together. I'm using D5 Enterprise, ASA 6.03 w/latest EBF On some tables it works. But most of the tables produce a message "An Error occured". As soon as data bound contols are used, the connection just gives errors. It seem to work fine, if I use client based cursors. But this option copys the server table to the local client. This is not acceptable for my large tables. It lasts several minutes on my pc. Are there plans to release a native OLE DB provider for ASA or at least to fix the ODBC driver so, that ADO can be used? I am very...

ADO not ADO.NET
Hi, I have to connect to a db using adodb (which i select from the references). I have to retrieve the car models from the database and bind them to a listbox. I am not sure how to proceed and I can't find any articles on ADO with .net and data binding. Here is the code that i tried but it only retrieves the car model for the specified id. If I delete the id it doesn't work. Also it writes the car model in the listbox vertically such as: B M W CODE: Imports System.Data Imports ADODB Imports System.Data.OleDb Public Class listboxADO Inherits System.Web.UI...

ADO to ADO.NET
I'm an ASP programmer (VBScript) moving on to ASP.NET. So far I'm using:Microsoft Visual Studio 2003ASP.NET with C#I'm working on converting my code over to C#, from VBScript. Now, here is my code in VBScript (modified to better understand it, this is a edited ugly version):Function ExecuteSQL(sqlStatement)    ConnDriver = "Provider=SQLOLEDB; Data Source = " & dbIP & "; Initial Catalog = " & dbName & "; User Id = " & dbUser & "; Password=" & dbPassword     Set connTemp = Server.CreateObject("ADODB.Connection")    c...

Delphi 2010, ADO and Datamodule
I installed Delphi 2010 on a Windows 7 x64. I have build a few applications using a datamodule and several Adodatasets, connecting to a SQL server. Until Delphi 2009 everything worked fine. When I open the project with 2010, I get an error, stating it can not find something, it probebly is not installed corectly. I tried reïnstalling without any succes. Projects with the sam AdO conecctions but no Datamodule run fine. Any sugestions? Regards, Kees Flipsen Kees Flipsen wrote: > I get an error, stating it can not find something, Do you really expect someone to be able...

Delphi + Long Binary + ADO
How can I update a long binary field in an ASA6 database using Delphi + ADO (not ADOExpress)? I have the blob in a string, but when trying to update the field, I get an "invalid variant conversion" error. If I re-type the field to a long varchar, the update seems to work, but I concerned that this may be affected by code page selection. Do I have to worry about raw bytes written to a long varchar not coming back in exactly the same form? From the database side of things, a LONG VARCHAR and LONG BINARY should be treated exactly the same way. I might try posting this ...

HELP! Trying to Complie old Delphi program on any version of Delphi
Hey everyone I'm new to the programming world and unfortunately I have come across a big problem that I will hope I can get some help with. I have a program that was apparently created using delphi 3 and then finished using delphi 4 with some additional parts added later. I have found copies of amost every version of delphi ever made and installed them on my pc and attempted to compile this program in question. Unfortuantely I have yet to get it to compile without a few thousand error messages and I am st uck between a rock and a hard place. I know very little of Delphi programming, let alone programming itself. I have to get this program to compile so I can make some changes to the program. By trade I am a PLC programmer and I program in ladder logic, so I understand generally how I can make things work. I don't have much experience with structured text programming or C or C+ which makes this all the more complicated for me. I have gone through quite a few tutorials various websites and forums had up to teach yourself how to navigate through the Delphi interface as well as how the basics of a program are created. I have created some simple windows based programs already using the tutorials, and generaly understand the structure of a program made with delphi. I know the program I need to compile works because it is running even right now on a server, I just need to make some changes. I was told it is not easy to just make a program compile without finding out...

Deploying Delphi software which uses ADO
Hi what needs to deployed and provided by Installaware type packages to get Delphi-based programs that use ADO to install on Windows 7 32 bit and 64 bit computers? When Googling for stuff I keep getting older information plus some comments that the Jet Engine is no longer fully supported for Windows 7 environments. Suggestions or links to good descriptions would be appreciated. Bruce On 2012-09-19 16:13:51, Bruce Eglington wrote: > what needs to deployed and provided by Installaware type packages > to get Delphi-based programs that use ADO to install on Windows 7 32...

ASA7 / ADO / Delphi 5.01
Has anyone figured out the problem with Delphi 5.01 and ASA7 via ADOExpress? All we get is Invalid Enum Value errors when trying to connect. Thanks, Rhett Price IndySoft Rhett, I've been informed by a Sybase representative in Norway that they are working on this problem, and hopefully have a fix in one of the first EBFs to come. Regards Ole Willy Tuv > Has anyone figured out the problem with Delphi 5.01 and ASA7 via ADOExpress? > All we get is Invalid Enum Value errors when trying to connect. ...

Web resources about - Several Delphi ADO Database help questions - embarcadero.delphi.ado

German question - Wikipedia, the free encyclopedia
"Kleindeutschland" redirects here. For the neighborhood in New York City, see Little Germany, Manhattan . 1820 map of Central Europe showing ...

Queensland Parliament live: Question Time February 16, 2016
Join our state political editor for her unique take on question time in Queensland Parliament.

Q&A recap: Tony Jones brings back program's controversial past with simple question
"Should people in a forum like this be able to say whatever they think?" inquired Q&A host Tony Jones during Monday night's program.

Q&A recap: Tony Jones brings back program's controversial past with simple question
"Should people in a forum like this be able to say whatever they think?" inquired Q&A host Tony Jones during Monday night's program.

Simple analysis can help ask right questions
Come every trade deadline, there’s one critical question a general manager looking to buy needs to be able to answer: Where is the drag on my ...

Five Questions With Cannes PR Lions Jury President John Clinton
The Cannes Lions International Festival of Creativity has appointed John Clinton, chair, Canada and North American head of creative and content ...

“Did Obama assassinate Scalia?” just became a serious question in the Republican primary
Donald Trump: Scalia death truther. Not satisfied with the explanation that sometimes overweight 79 year-olds die in their sleep, Donald Trump ...

Asked "What's your greatest hope for the next 10 years?" — who resisted the question the most?
You hear, in order, from Heather Hurlburt, Bill Scher, Matt Lewis, Sarah Posner, Robert Farley, Megan McArdle, Matthew Yglesias, Andrew Sullivan, ...

MARK CUBAN: Bloomberg should run for president, but there's one big question about his viability
Dallas Mavericks owner Mark Cuban thinks fellow billionaire Michael Bloomberg would be a positive addition to the 2016 presidential race. "I'd ...

St. Ronnie Speaks On Question Of SCOTUS Confirmation In Final Year
I'll just leave it right here for everyone to see for themselves. Watch Ronald Reagan urge the Senate to confirm Justice Kennedy during an election ...

Resources last updated: 2/17/2016 7:23:43 AM