liljen_80
asked on
Connect to a MSSQL database
I'm a novis in database connections.
My problem is that I have a MSSql (Microsoft SQL) database I need connection to. How too get connected too the database that is on a server.
Is it ADO that is best suited for the task or is it somthing else? And it is an other database with the same name on the server witch is accessed with ODBC so I have too be certen it is not that one I get connetcted on.
And i'm not using .net.
I'm using Borland Developer Studio 2006 by the way.
My problem is that I have a MSSql (Microsoft SQL) database I need connection to. How too get connected too the database that is on a server.
Is it ADO that is best suited for the task or is it somthing else? And it is an other database with the same name on the server witch is accessed with ODBC so I have too be certen it is not that one I get connetcted on.
And i'm not using .net.
I'm using Borland Developer Studio 2006 by the way.
ASKER
Oki, that was what I tought. But I dont get in anny conflicts with the other database witch my be accessed by ODBC?
I have been locking for a site on the internet with some explenation on how too use ADO but I cant find anny good one, someone knows anny site?
I have been locking for a site on the internet with some explenation on how too use ADO but I cant find anny good one, someone knows anny site?
nope there shouldn't be any conflicts with ODBC
for samples of ADO go to: \Program Files\Borland\BDS\4.0\Demo s\DelphiWi n32\VCLWin 32\ADO
ziolko.
for samples of ADO go to: \Program Files\Borland\BDS\4.0\Demo
ziolko.
ASKER
Yea it was an example there, but it was very complex.
Does sombody have a simple solution on how and get a list of the tabels and how too conect a ADOTable to a database.
Does sombody have a simple solution on how and get a list of the tabels and how too conect a ADOTable to a database.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You have to modify ConnectionString and TableName to your values
ziolko.
ziolko.
ASKER
But how is it possible too make a list of the TableNames where the user my pick witch Table too show?
use ADOCOnnection.GetTableName s() display result for user when user selects table asign it's name to ADOTable.TableName and then set ADOTable.Active := True
ziolko.
ziolko.
ASKER
I solved the last problem my self.
But I got a problem when I'm going into the database fore the first time. I get up that I have too write in the password and username. But it does not mather what i write, I get into the database no mater what I write.
This is the ConnectionString: Provider=SQLOLEDB.1;Integr ated Security=SSPI;Persist Security Info=False;Initial Catalog=HET;Data Source=OLE\BERE
But I got a problem when I'm going into the database fore the first time. I get up that I have too write in the password and username. But it does not mather what i write, I get into the database no mater what I write.
This is the ConnectionString: Provider=SQLOLEDB.1;Integr
thats because You selected "Use Windows NT Integrated Security" and therfore in connection to DB security context of logged on user (logged on to computer) is used instead of login/password You specify.
You can either set ADOCOnnection.LoginPrompt := False to use logged on user or remove >>Integrated Security=SSPI;<< from Your connection string (same as uncheck "Use Windows NT Integrated Security")
ziolko.
You can either set ADOCOnnection.LoginPrompt := False to use logged on user or remove >>Integrated Security=SSPI;<< from Your connection string (same as uncheck "Use Windows NT Integrated Security")
ziolko.
ASKER
It worked with ADOCOnnection.LoginPrompt := False, thanks.
This is how I alter a table:
if ADOTable1.Locate('ID',45,[ loCaseInse nsitive]) then
begin
ADOTable1.Edit;
ADOTable1.FieldByName('ID' ).AsIntege r := 65;
ADOTable1.Refresh;
end;
But how too do this so that nobody other get access to alter this while I'm doing the change. Besause if it is done the way my code is it is generated an error, but I need it so that the last one dont get too do the altering and just continues.
This is how I alter a table:
if ADOTable1.Locate('ID',45,[
begin
ADOTable1.Edit;
ADOTable1.FieldByName('ID'
ADOTable1.Refresh;
end;
But how too do this so that nobody other get access to alter this while I'm doing the change. Besause if it is done the way my code is it is generated an error, but I need it so that the last one dont get too do the altering and just continues.
ASKER
The error message is:
Row can not bi located for updating. Some values may been changed since it was last read.
Row can not bi located for updating. Some values may been changed since it was last read.
try ADOTable1.Post instead ADOTable1.Refresh;
ziolko.
ziolko.
ASKER
I have some more problems with ADO database connection, I would appreciate if you would take a look at this problem
https://www.experts-exchange.com/questions/22054714/ADO-and-Pervasive.html
Regards
Jan
https://www.experts-exchange.com/questions/22054714/ADO-and-Pervasive.html
Regards
Jan
ziolko.