Ok... I finished my coffee long time ago and I'm all awake :)

    In one of the applications I work on, clients can have several
companies, each company has its own database and we have a common database
for all the companies containing general data, like daily currency rates,
operators table, languages, etc...

    Since each company has its own database, each company has its own
connection in its properties, so every time a new company is created in the
application, a new connection is created at run time. Every time the user
switches between company 1 and company 2 let's say, all the data aware
components get their data from the active connection to display the data of
the current company

    From your first post, I understand that you want to access some data
from DB2 on button click. maybe this example might help you

private
  vConnection: TMsConnection;


procedure TForm1.Button1Click(Sender: TObject);
begin
  vConnection                          := TMSConnection.Create(Self);
  vConnection.ConnectionString := // fill some values here
  try
    vConnection.Connected := true;
    // now let's say I have a TMSTable component connected to a table which
will show the data contents in a grid
    Table1.Connection        :=  vConnection
    Table1.Open;
  except
    // handle any expectation here in case could not connect to DB
  end;
end;

  This will allow you to connect to any database you want (while you are
already connected to a database) and operate on it.

    N.B.- Do not forget to free the connection before terminating your
application or module.

Hope this helped

Vahan

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] Behalf
Of soonhuat ong
Sent: Tuesday, September 27, 2005 9:37 AM
To: [email protected]
Subject: RE: [delphi-en] 2 MsSQL + Delphi question


Sorry, I'm just too new with this MsSQL + Delphi thing.

In your example, there's only 2 connection available. What about if there's
3 or more database for users to choose ? does that mean i have to create the
data-aware component in my application ? It's way too hard for me, some
sample code on button click event would be appreciated. Waiting for your
help after u have finished your coffee haha

Vahan Yoghoudjian <[EMAIL PROTECTED]> wrote:
1) Knowing that you could be running this SQL statement at 00:01, both date
and time are important for you to do your checking. I'm still drinking my
morning coffee and haven't launched SQL Server or any application yet, but
what you have to do is something like this, if you check the date and time
functions you will surely find your way.

select * from table where (PostDateTime > (SystemDateTime - 2)). Just find
the function that subtracts 2 minutes from a given date time.

2) Well, there are 2 levels to do this. First at database level, second at
application level. First you have to make sure that the user has access to
both databases. At database level, you can use any view or stored procedure
to refer to the second database.

select "servername.databasename.tablename.fieldname" from
"servername.databasename.tablename"

You can even fetch data from databases on differnet servers. If your data is
residing on the same server you can skip the servername, if your data is
residing in the same database you can skip the database name, etc...

    At application level, you have to have a connection/database component
(depends which data aware components you are using) for each database. if
you're using SDAC components let's say, TMSConnection1 will be connected to
database one and TMSConnection2 to database2. Any data-aware component you
will be creating in your application will be assigned one of those
connections, hence one of the databases you want to connect to

Hope this helps
if you need more help I'll be glad to give more details after my coffee :)

Vahan

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] Behalf
Of soonhuat ong
Sent: Tuesday, September 27, 2005 5:03 AM
To: [email protected]
Subject: [delphi-en] 2 MsSQL + Delphi question


Hi all,

I have 2 questions regarding MsSQL + Delphi appllication here:

1) In my table, i have a field named 'PostDateTime', which is of type
DateTime.
   This field is basically to store the Datetime when record been update to
the database.
   Now my question is :-  What's the query to select only the records where
PostDateTime is
   2 minutes earlier than current PC time ?

2) I have two .MDF database files (DB1.MDF and DB2.MDF). The path for
DB1.MDF is
    C:\DB1.DBF, where the path for DB2.MDF is D:\DB2.MDF. Both of the
database have the
    same Database structure , but differents records. Let's say now my
application is
    connected to DB1.MDF. Is there any way for me to browse and connect to
DB2.MDF when
    user click at certain button ? I know it can be  easily done for
Firebird, Interbase etc. But
    what about MsSQL ?

Hope someone can answer my question. Thanks.

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

[Non-text portions of this message have been removed]



-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]



SPONSORED LINKS Basic programming language  C programming language  Computer
programming languages
      The c programming language  C programming language  List of
programming languages


----------------------------------------------------------------------------
----
YAHOO! GROUPS LINKS

  a..  Visit your group "delphi-en" on the web.

  b..  To unsubscribe from this group, send an email to:
   [EMAIL PROTECTED]

  c..  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


----------------------------------------------------------------------------
----





[Non-text portions of this message have been removed]



-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]



SPONSORED LINKS
Basic programming language C programming language Computer programming
languages The c programming language C programming language List of
programming languages

---------------------------------
YAHOO! GROUPS LINKS


    Visit your group "delphi-en" on the web.

    To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

    Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


---------------------------------




---------------------------------
Yahoo! for Good
Click here to donate to the Hurricane Katrina relief effort.

[Non-text portions of this message have been removed]



-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]



SPONSORED LINKS Basic programming language  C programming language  Computer
programming languages
      The c programming language  C programming language  List of
programming languages


----------------------------------------------------------------------------
----
YAHOO! GROUPS LINKS

  a..  Visit your group "delphi-en" on the web.

  b..  To unsubscribe from this group, send an email to:
   [EMAIL PROTECTED]

  c..  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


----------------------------------------------------------------------------
----





[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/T8sf5C/tzNLAA/TtwFAA/i7folB/TM
--------------------------------------------------------------------~-> 

-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED] 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/delphi-en/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to