Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I open a SQL Anywhere ".db" file? 2

Status
Not open for further replies.

randall2nd

Programmer
May 30, 2001
112
US
I have been tasked to create an application that will access a "mydata.db" file.
I am using Delphi 7 on Windows 2000.
What I know about the file:
It was being used in a Powerbuilder 6.0 desktop application
When I open it in word pad it references
"WATCOM International Corp.., Copyright (c) 1987, 1994"
It is approximately 8.7MB file

From the web searches I have done i am guessing that it is a SQL Anywhere file.

What I do not know:
How to access the information in it.
What driver to use.
Where to get the driver.

From the posts that i have read I am thinking that I will need to make an ODBC connection to the file through the BDE, and then use that alias in the Delphi app. But I cannot seem to figure out a way to do this. Is this the best way to go about this?

I do not have access to ODBCexpress, Titan, or NativeDb.

Please be as specific and detailed as possible, as you can probably tell alot of this is still new to me.

Please help, I am willing to try anything, so ANY ideas will help.
Randall2nd
 
Hi,
If it is a Sybase(now Adaptive) SQL-Anywhere you have to install it on your PC: it could be Stand-Alone or Client-Server.

After the installation you will be able to make your ODBC entry to connect with your database using BDE, ADO etc.

To do this run the ODBC manager, System DSN, [Add], choose Adaptive Server Anywhere 8, and then fill
[ODBC] DataSourceName with MyOdbcToAnywhere //You will find this later in Delphi
[Login] UserID:dba Password:sql //default usr & pwd
[Database] [Browse] and fill the DatabaseFile.
This is the minimun required to let it work as stand-alone.
After this Open Delphi, put a [BDE].TDatabase on a form,
in Database1.AliasName you will find MyOdbcToAnywhere.
Give a DatabaseName (for example MyOdbcToAnywhereInForm1) and refer Table1.DatabseName to MyOdbcToAnywhereInForm1.

With Ado is the same: ADOConnection1.ConnectionString [Build]->Microsoft OleDBProvider for ODBC,DataSourceNAme->MyOdbcToAnywhere

Using Client-Server is transparent to Delphi: you should have a runnig DatabaseServer Start->Run->"C:\Programmi\Sybase\SQL Anywhere 8\win32\dbsrv8.exe" -c 8m -n asademo8 "C:\Programmi\Sybase\SQL Anywhere 8\asademo.db"
this publish the server with the name asademo8 (-n asademo8).
in ODBC Setting you should put asademo8 in ServerName and DatabaseName instead of DatabaseFile (if my memory works well).

Thats all.

P.S. if you still have problems try to open the database with SybaseCentral. 90% of times the problems belongs to the log file, wich is created at a fixed position (C:\pippo\adfsjf\MyDb.log) Just remove it from SybaseCentral->ChangeLogFileinformations.

Hope this can be usefull.

Ciao,
GeppoDarkson.
 
Wow! :) thanks for the info, very explanatory.

You said:
"If it is a Sybase(now Adaptive) SQL-Anywhere you have to install it on your PC: it could be Stand-Alone or Client-Server."
I am pretty sure it is stand alone, since the original app connected to it on the same desktop machine.

My question on this is, How do I install "it"? All I have is just the file "mydata.db". I do not have powerbuilder on the same machine as I have Delphi. Is there way to get to the driver for ASA, or the files to install it from Powerbuilder. Is there a site to download these install files? Is there a way to connect to it without using the BDE or installing any files?
Randall2nd
 
Hi,
Note that PowerBuilder probably don't use ODBC to connect to the database, it uses internal "private" links.

Usually you should have a Sybase SQLAnywhere CD to install the database.
I don't say you should try to get a copy of this CD, but...

If You don't have it, check if you have at least all the required dll installed, then make a "very dirty" hand-made
ODBC installation following this steps:

1) Look if you have
C:\Programmi\Sybase\SQL Anywhere 8\win32\dbodbc8.dll
or something like dbodbc[VersionNr].dll
If you don't have it, you're out.

2) Regedit the registry and add the following node (If miss)
**** REGISTRY ******************************************
HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\Adaptive Server Anywhere 8.0
Under this node i have tree values (in italian)
NOME TIPO DATI
(Predefinito) REG_SZ (valore non impostato)
Driver REG_SZ C:\Programmi\Sybase\SQL Anywhere 8\win32\dbodbc8.dll
Setup REG_SZ C:\Programmi\Sybase\SQL Anywhere 8\win32\dbodbc8.dll
**** End REGISTRY ******************************************


In C:\Winnt\ODBCI.INI
**** ODBCI.INI ******************************************
[ODBC 32 bit Data Sources]
MyOdbcToAnywhere=Adaptive Server Anywhere 8.0 (32 bit)

[MyOdbcToAnywhere]
Driver32=C:\Programmi\Sybase\SQL Anywhere 8\win32\dbodbc8.dll
**** End ODBCI.INI *****************************************

I'm not sure it can work,
I strongly raccomand You to install ODBC Drivers using the setup CD.

Ciao,
GeppoDarkson.

 
THANKS A BUNCH !!!! [bigsmile]

I will try and see if I can scrounge up an install CD of somesort, I am guessing that there should at least be one around for installing Powerbuilder. Hopefully that should have what I need.

If not I will have to go scrounging for the dll you mentioned. And have to do the "dirty" connect.

Thanks again for all your help
[2thumbsup] Randall2nd
 
If I wanted to use ms sql in my delphi how would I do that?
Please have mercy on me, I'm like a fish out of water if i'm not using paradox. But I understand that paradox is no good for a multi-user environment.
I use a stand alone delphi 4, and it dosen't even have interbase though I have interbase from my delphi2 cd.
I can't even get interbase tables to show in my D4 ide i.e I don't know how to connect to them.
The database component is not clear. Please if you say datamodules, then please explain them well, well, 'cause I don't even know what they are.
I remain ignorant....
but thanks in-advance for oyur help.
yom-yom.
 
Hi,
Using Paradox table or SQL-Server it's not so different:
Take the BDE as example (even if it's officially death)

You put a TDabase on the form.
The AliasName can be filled either with a BDE alias or with a ODBC entry (that you should create before).
After this, put a TTAble, and give it the DatabaseName=Database1.DatabaseName

If It refers to a BDE Alias, when you open the TTable.TableName lookup you will find all the tables in that alias (C:\Programmi\File comuni\Borland Shared\Data\*.db)
If TDabase.AliasName is a valid ODBC entry to SQLServer you will find the tables inside the database.
That's all.
From here on you can work (more or less) in the same way.

To clear some trouble on TDatabase:
** TDatabase.AliasName refers to an ODBC-Entry or BDE Alias
** TDatabase.DatabsaeName is the name you should put in ** TTAble.DatabaseName: by doing so you can change the TDatabase.AliasName From "WorkAlias" to "TestAlias" and all the TTAbles and TQuery taken the data from the new location.
** TDatabase.DriverName: the kind of "connection" you are using: PARADOX (internal via BDE), ODBC; DirectLinks and so on.

Note that you can access MS-SQLServer via ODBC or via "DirectLink".
The simplest way is to use ODBC as described in the first reply, because the second way should be faster but more complex to setup.

Ciao,
Geppo Darkson.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top