Hi,

in the catch section , use infolog.clear().

Regards
Akash

--- [EMAIL PROTECTED] wrote:


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

Hi Thomas,

thank u very much. it is working. one more doubt is
when i give wrong
userid/password, it shows system error. to prevent
this, i write the code
within the try catch exception block. but, system
shows both the system
provided error and also the following exception error.
how to suppress the
system error? pls. provide the solution. sorry for the
trouble agin. Thank
u.

     catch (Exception::Error)
     {
          error("Could not connect to database
server");
     }


regs,
Hema. S




                                                     
                                                     
                    
                    "Thomas Jensen"                  
                                                     
                    
                    <[EMAIL PROTECTED]>                 
  To:     <Axapta-Knowledge-Village@yahoogroups.com> 
                    
                    Sent by:                         
  cc:                                                
                    
                    [EMAIL PROTECTED]   
  Subject:     SV: SV: SV: [Axapta-Knowledge-Village]
how do i get the     
                    groups.com                       
   database server names, database names             
                    
                                                     
                                                     
                    
                                                     
                                                     
                    
                    05/15/2006 01:23 PM              
                                                     
                    
                    Please respond to                
                                                     
                    
                    Axapta-Knowledge-Village         
                                                     
                    
                                                     
                                                     
                    
                                                     
                                                     
                    




Hi Hema

If you want to validate the password you should
connect using the loginid
and password. If you want to verify which databases
the user has been
granted access to you can use the EnumDatabaseMappings
method on the login
object.

Example:

static void TestDatabaseAccess(Args _args)
{
    str serverName  = "(local)";
    str loginId     = "testuser";
    str password    = "password";

    COM sqlServer = new COM("SQLDMO.SQLServer");
    COM logins;
    COM login;
    COM databases;
    int i;
    int j;
    ;
    try
    {
      
sqlServer.connect(servername,loginid,password);

        logins = sqlServer.logins();
        for (i=1;i<=logins.count();i++)
        {
            login = logins.item(i);
            if (login.name()==loginId)
            {
                databases =
login.EnumDatabaseMappings();
                for (j=1;j<=databases.rows();j++)
                {
                  
info(databases.getColumnString(j,2));
                }
            }
        }

    }
    catch (Exception::Error)
    {
        error("Could not connect to database server");
    }
}

For documentation of the SQL-DMO object take a look
here:

http://msdn.microsoft.com/library/default.asp?url="">



Regards
Thomas


-----Oprindelig meddelelse-----
Fra: Axapta-Knowledge-Village@yahoogroups.com
[mailto:[EMAIL PROTECTED] På
vegne af
[EMAIL PROTECTED]
Sendt: 12. maj 2006 06:00
Til: Axapta-Knowledge-Village@yahoogroups.com
Emne: RE: SV: SV: [Axapta-Knowledge-Village] how do i
get the database
server names, database names


Hi,

i think it will work only after creating datasource.
but, i dont want to
use odbc connection. in the following code, tell me
how to check with user
password.

    COM com = new COM("SQLDMO.Application");
    COM servers = com.ListAvailableSQLServers();
    COM sqlserver;
    COM sqlserver1;
    COM databases;
    COM database;
    COM users;
    COM user;
    COM Passwords;
    COM Pwd;
    int i;
    int j;
    int k;
    ;
    setprefix("SQL Servers");
        try
        {
            sqlserver = new COM("SQLDMO.SQLServer");
            sqlserver1 = new COM("SQLDMO.SQLServer");

              
sqlserver.connect(ListofSqlServers.getEditText());

                databases = sqlserver.databases();
                for (j=1;j<=databases.count();j++)
                {
                    database = databases.item(j);
                    setprefix(database.name());
                  
if(database.name()==Databasename.text()) //user input
value)
                    {
                        users = database.users();
                        for (k=1;k<=users.count();k++)
                        {
                            user = users.item(k);
                            setprefix(user.name());
                          
if(user.name()==userid.text()) //user input
value)
                            {
                                //here i want to check
the user password.
only after that i will show                          
//message it is a
valid connection

                                info('Valid
connection');

                            }
                        }
                    }
                }

        }
        catch (Exception::Error)
        {
            error("Please check the data entered.
Connection could not be
established based on the values provided");

        }


regs,
Hema. S





                    "Bayliss, Barry"

                    <[EMAIL PROTECTED]>            
  To:
<Axapta-Knowledge-Village@yahoogroups.com>
                    Sent by:                         
  cc:

                    [EMAIL PROTECTED]   
  Subject:     RE:
SV: SV: [Axapta-Knowledge-Village] how do i get the
                    groups.com                       
   database server
names, database names


                    05/11/2006 04:23 AM

                    Please respond to

                    Axapta-Knowledge-Village








Hema,

There is a simpler way to do this, and it can be done
using X++.

Here is an extract of code I use

ODBCConnection
      FormConnection
      (
      )
{
    #PCDMacro
    LoginProperty               loginDetails       =
new LoginProperty();
    ODBCConnection              currentconnection;
    str                         Database,
CurrentServer,
CurrentApplication;
    int                         pos;
    ;


    // Create the connection
    database            =
sqlsystem::databaseBackendDesc();

      <. processing the database variable to get the
information I
require.>

    LoginDetails.setDatabase(Database);
    logindetails.setUsername(#loginname);
    logindetails.setPassword(#logincode);

    currentconnection = new
ODBCConnection(logindetails);
    return currentconnection;
}

As you see, you can supply:
      1. The database. In this case I use the
currently connected database
to determine which database I will connect to.
      2. The login name.  In this case it is stored in
a macro.
      3. The password.  In this case it is stored in a
macro.

While this example uses an ODBC connection, there may
be other connection
types that can also be used.


Thomas, thanks for the code for supplied.

Barry.

p.s. Hema, by describing your requirement you made it
a lot easier to
address your issue.







-----Original Message-----
From: Axapta-Knowledge-Village@yahoogroups.com
[mailto:[EMAIL PROTECTED] On
Behalf Of
[EMAIL PROTECTED]
Sent: Wednesday, 10 May 2006 3:22 PM
To: Axapta-Knowledge-Village@yahoogroups.com
Subject: Re: SV: SV: [Axapta-Knowledge-Village] how do
i get the database
server names, database names

Hi,

thank u very much. i'll tell u my requirement. the
user will enter the
servername, database name, userid and password. i have
to make test connect
for the given data. if it does not connect, then throw
the error.

ex:
----
server name - axapta server
db name - EAM
user id - Hema
password - Hema

i want to check the connection for the above data. if
it fails, then throw
error. i tried. but, i dont know how to make test
connection for the above.
i specify database name from the input value as
server.databases("axapta
server"). it gives error (number of invalid
argument"). how do i do?

u specified
                database = databases.item(j);
                setprefix(database.name());
but, i want to give the database name from the user
input value. how do i
give?


pls. provide the solution. sorry for the trouble.
Thank u.


regs,
Hema. S





                    "Thomas Jensen"

                    <[EMAIL PROTECTED]>                 
  To:
<Axapta-Knowledge-Village@yahoogroups.com>
                    Sent by:                         
  cc:

                    [EMAIL PROTECTED]   
  Subject:     SV:
SV: [Axapta-Knowledge-Village] how do i get the
database
                    groups.com                       
   server names,
database names

                    05/09/2006 06:35 PM

                    Please respond to

                    Axapta-Knowledge-Village







Hi Hema S

This job will show SQL Servers, their databases and
the usernames for each
database. Obviously you will need appropriate trusted
login rigths for the
server to retrrive this information. The login names
can also be retrieved
from one of the DMO objects but obviously it's not
possible to retrieve the
passwords for the logins for security reasons.

Regards
Thomas


static void ListSQLServers(Args _args)
{
    COM com = new COM("SQLDMO.Application");
    COM servers = com.ListAvailableSQLServers();
    COM sqlserver;
    COM databases;
    COM database;
    COM users;
    COM user;
    int i;
    int j;
    int k;
    ;
    setprefix("SQL Servers");
    for (i=1;i<=servers.count();i++)
    {
        setprefix(servers.item(i));
        try
        {
            sqlserver = new COM("SQLDMO.SQLServer");
            sqlserver.loginsecure(true);
            sqlserver.connect(servers.item(i));
            databases = sqlserver.databases();
            for (j=1;j<=databases.count();j++)
            {
                database = databases.item(j);
                setprefix(database.name());
                users = database.users();
                for (k=1;k<=users.count();k++)
                {
                    user = users.item(k);
                    info(user.name());
                }
            }
        }
        catch (Exception::Error)
        {
            info("Could not connect to server");
        }
    }
}



________________________________

Fra: Axapta-Knowledge-Village@yahoogroups.com på vegne
af
[EMAIL PROTECTED]
Sendt: ti 09-05-2006 12:31
Til: Axapta-Knowledge-Village@yahoogroups.com
Emne: Re: SV: [Axapta-Knowledge-Village] how do i get
the database server
names, database names




Hi Thomas,

Thank u. it is working fine. pls. kindly tell me how
do i get the databases
names
under the selected server and also its corresponding
userid and
password. urgent.


regs,
Hema. S





                    "Thomas Jensen"

                    <[EMAIL PROTECTED]>                 
  To:
<Axapta-Knowledge-Village@yahoogroups.com>
                    Sent by:                         
  cc:

                    [EMAIL PROTECTED]   
  Subject:     SV:
[Axapta-Knowledge-Village] how do i get the database
                    groups.com                       
   server names,
database names


                    05/09/2006 12:56 PM

                    Please respond to

                    Axapta-Knowledge-Village







Try this:
static void ListSQLServers(Args _args)
{
    COM com = new COM("SQLDMO.Application");
    COM servers = com.ListAvailableSQLServers();
    int i;
    ;
    for (i=1;i<=servers.count();i++)
        info(servers.item(i));
}

regards
Thomas

________________________________

Fra: Axapta-Knowledge-Village@yahoogroups.com på vegne
af
[EMAIL PROTECTED]
Sendt: ti 09-05-2006 09:07
Til: Axapta-Knowledge-Village@yahoogroups.com;
development-axapta@yahoogroups.com
Emne: [Axapta-Knowledge-Village] how do i get the
database server names,
database names




Hi,

how do i get all the database server names from all
the machines in an
organization?

ex:
-----
in aos settings, we can see the list of database
servers against Server
combo. how do i get all those names thro' x++ coding?
based on the
selection of server, i want to get the database names.
again i want to get
the userid and password of the specified database
name.

wherever sql server is installed in the machines, all
the server names and
its corresponding database names, userid and password
should be displayed
in the combo. how do i do?


pls. provide the solution. urgent.


regs,
Hema. S






Sharing the knowledge on Axapta.
Visit www.frappr.com/axapta for axapta friends.
Yahoo! Groups Links













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



Sharing the knowledge on Axapta.
Visit www.frappr.com/axapta for axapta friends.



                                                     
     SPONSORED LINKS

Business finance   Business to        Small business
course             business finance   finance

Business finance   Business finance   Business finance
consultant         magazine           schools



                            YAHOO! GROUPS LINKS

      Visit your group "Axapta-Knowledge-Village" 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.








Sharing the knowledge on Axapta.
Visit www.frappr.com/axapta for axapta friends.



                                                     
     SPONSORED LINKS

Business finance   Business to        Small business
course             business finance   finance

Business finance   Business finance   Business finance
consultant         magazine           schools



                            YAHOO! GROUPS LINKS

      Visit your group "Axapta-Knowledge-Village" 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.








Sharing the knowledge on Axapta.
Visit www.frappr.com/axapta for axapta friends.
Yahoo! Groups Links












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



Sharing the knowledge on Axapta.
Visit www.frappr.com/axapta for axapta friends.



                                                     
     SPONSORED LINKS

Business finance   Business to        Small business
course             business finance   finance

Business finance   Business finance   Business finance
consultant         magazine           schools



                            YAHOO! GROUPS LINKS

      Visit your group "Axapta-Knowledge-Village" 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.









Sharing the knowledge on Axapta.
Visit www.frappr.com/axapta for axapta friends.
Yahoo! Groups Links









Sharing the knowledge on Axapta.
Visit www.frappr.com/axapta for axapta friends.



                                                     
     SPONSORED LINKS

Business finance   Business to        Small business
course             business finance   finance

Business finance   Business finance   Business finance
consultant         magazine           schools



                            YAHOO! GROUPS LINKS

      Visit your group "Axapta-Knowledge-Village" 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.









Sharing the knowledge on Axapta.
Visit www.frappr.com/axapta for axapta friends.
Yahoo! Groups Links











Sharing the knowledge on Axapta.
Visit www.frappr.com/axapta for axapta friends.



                                                     
     SPONSORED LINKS
                                                     

Business finance   Business to        Small business

course             business finance   finance       

                                                     

Business finance   Business finance   Business
finance
consultant         magazine           schools       

                                                     



                            YAHOO! GROUPS LINKS

      Visit your group "Axapta-Knowledge-Village" 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.








Sharing the knowledge on Axapta.
Visit www.frappr.com/axapta for axapta friends.

     

      SPONSORED LINKS 
                                              
Business finance course                              
    Business to business finance                     
             Small business finance                  
                                            Business
finance consultant                                  
Business finance magazine                            
      Business finance schools                       
                           
   
---------------------------------
  YAHOO! GROUPS LINKS

 
    Visit your group "Axapta-Knowledge-Village" 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.

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




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


Sharing the knowledge on Axapta.
Visit www.frappr.com/axapta for axapta friends.




SPONSORED LINKS
Business finance course Business to business finance Small business finance
Business finance consultant Business finance magazine Business finance schools


YAHOO! GROUPS LINKS




Reply via email to