Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > DB-Aware

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 12-20-2001, 04:27 AM
dzungnv dzungnv is offline
Junior Member
 
Join Date: Dec 2001
Posts: 1
Default How can I create a ODBC data source name ?

Please show me the way to create a ODBC data source name by Delphi or by InstallShield ?
Thanks lot
Reply With Quote
  #2  
Old 12-20-2001, 01:38 PM
Beardawg Beardawg is offline
Member
 
Join Date: Mar 2001
Posts: 75
Default RE: How can I create a ODBC data source name ?

There are two ways to do this... You can create a text file and write the information to that text file and name it whatever.dsn. For example, this is the code from a CreateDSN procedure from a Component I wrote to do exactly what you are asking for...

var
DSNTempName: TextFile;

if DSNName = '' then
begin
DSNFile := FileDirectory + '\Temp.dsn';
end else
begin
DSNFile := FileDirectory + '\' + DSNName + '.dsn';
end;
AssignFile(DSNTempName, DSNFile);
Rewrite(DSNTempName);
WriteLn(DSNTempName, '[ODBC]');
WriteLn(DSNTempName, 'DRIVER=Microsoft Access Driver (*.mdb)');
WriteLn(DSNTempName, 'UID=admin');
WriteLn(DSNTempName, 'UserCommitSync=Yes');
WriteLn(DSNTempName, 'Threads=3');
WriteLn(DSNTempName, 'SafeTransactions=0');
WriteLn(DSNTempName, 'PageTimeout=5');
WriteLn(DSNTempName, 'MaxScanRows=8');
WriteLn(DSNTempName, 'MaxBufferSize=2048');
WriteLn(DSNTempName, 'FIL=MS Access');
WriteLn(DSNTempName, 'DriverId=25');
WriteLn(DSNTempName, 'DefaultDir=' + FileDirectory);
WriteLn(DSNTempName, 'DBQ=' + FileName);
CloseFile(DSNTempName);


This is for an MS Access database... This should get you started... Good luck!
Reply With Quote
  #3  
Old 12-20-2001, 01:38 PM
Beardawg Beardawg is offline
Member
 
Join Date: Mar 2001
Posts: 75
Default RE: How can I create a ODBC data source name ?

You can create a text file and write the information to that text file and name it whatever.dsn. For example, this is the code from a CreateDSN procedure from a Component I wrote to do exactly what you are asking for...

var
DSNTempName: TextFile;

if DSNName = '' then
begin
DSNFile := FileDirectory + '\Temp.dsn';
end else
begin
DSNFile := FileDirectory + '\' + DSNName + '.dsn';
end;
AssignFile(DSNTempName, DSNFile);
Rewrite(DSNTempName);
WriteLn(DSNTempName, '[ODBC]');
WriteLn(DSNTempName, 'DRIVER=Microsoft Access Driver (*.mdb)');
WriteLn(DSNTempName, 'UID=admin');
WriteLn(DSNTempName, 'UserCommitSync=Yes');
WriteLn(DSNTempName, 'Threads=3');
WriteLn(DSNTempName, 'SafeTransactions=0');
WriteLn(DSNTempName, 'PageTimeout=5');
WriteLn(DSNTempName, 'MaxScanRows=8');
WriteLn(DSNTempName, 'MaxBufferSize=2048');
WriteLn(DSNTempName, 'FIL=MS Access');
WriteLn(DSNTempName, 'DriverId=25');
WriteLn(DSNTempName, 'DefaultDir=' + FileDirectory);
WriteLn(DSNTempName, 'DBQ=' + FileName);
CloseFile(DSNTempName);


This is for an MS Access database... This should get you started... Good luck!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:46 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.