Showing posts with label method. Show all posts
Showing posts with label method. Show all posts

Monday, March 26, 2012

How determine how a Context menu was closed?

Hello,
I need to be able to determine the method used to close a Context menu. It
appears that there are three possibilities: 1) a menu selection was clicked,
2) the User clicked outside the menu or 3) the User hit ESC. I need to
determine if the menu closed due to either of the last two possiibilities.
(This may seem like a mysterious requirement but the popup of the Context
Menu is triggered by a specific event in a Frame. If a menu selection is
made then certain actions are taken but if the User "cancels" by items #2 or
#3 I need to take a different action to "clean up").
TrackPopupMenu() blocks and does not return until the menu has been closed,
but this happens before the handler for a selected menu item (if an item was
choosen) is called. That means that upon return from TrackPopupMenu() I
can't tell yet if a menu item was selected (since, if a handler is going to
fire, it hasn't yet fired). WM_EXITMENULOOP is also sent when the menu
closes but I can't depend that this will always been sent/processed *AFTER*
any possible menu selection message so I hacve the same problem with using
that.
So the question boils down to how can I, upon return from WM_EXITMENULOOP(),
detect how the menu was closed? I guess I could "go to sleep" for one
second upon return to give any possible menu selection message time to hit
its handler but that seems like a big kludge and I'm not sure how long I'd
have to wait to be sure.
Thanks.
Al
AlKoch@.MyRealBoxREMOVEALLTHESECHARS.comSorry - please ignore - obviously sent to wrong group!
Al

How determine how a Context menu was closed?

Hello,
I need to be able to determine the method used to close a Context menu. It
appears that there are three possibilities: 1) a menu selection was clicked,
2) the User clicked outside the menu or 3) the User hit ESC. I need to
determine if the menu closed due to either of the last two possiibilities.
(This may seem like a mysterious requirement but the popup of the Context
Menu is triggered by a specific event in a Frame. If a menu selection is
made then certain actions are taken but if the User "cancels" by items #2 or
#3 I need to take a different action to "clean up").
TrackPopupMenu() blocks and does not return until the menu has been closed,
but this happens before the handler for a selected menu item (if an item was
choosen) is called. That means that upon return from TrackPopupMenu() I
can't tell yet if a menu item was selected (since, if a handler is going to
fire, it hasn't yet fired). WM_EXITMENULOOP is also sent when the menu
closes but I can't depend that this will always been sent/processed *AFTER*
any possible menu selection message so I hacve the same problem with using
that.
So the question boils down to how can I, upon return from WM_EXITMENULOOP(),
detect how the menu was closed? I guess I could "go to sleep" for one
second upon return to give any possible menu selection message time to hit
its handler but that seems like a big kludge and I'm not sure how long I'd
have to wait to be sure.
Thanks.
Al
AlKoch@.MyRealBoxREMOVEALLTHESECHARS.com
Sorry - please ignore - obviously sent to wrong group!
Al
sql

Wednesday, March 21, 2012

How check user name?

I have COM object working with database via connection with administrative
rights.
I need method for checking user name: can this user has db access or no.
I want to check:
1. SQL Server users
2. Windows users which added as a SQL Server logins/db users
3. Windows users which can connect to db as a members of windows groups
added to SQL Server.
Thnx.have you looked into using SQL-DMO. The object model has collections and
methods to do all you ask.
regards,
Mark Baekdal
MSN m_baekdal@.hotmail.com
+44 (0)141 416 1490
+44 (0)208 241 1762
http://www.dbghost.com
http://www.innovartis.co.uk
Build, Comparison and Synchronization from Source Control = Database change
management for SQL Server
"Oleg Cherkasenko" wrote:

> I have COM object working with database via connection with administrative
> rights.
> I need method for checking user name: can this user has db access or no.
> I want to check:
> 1. SQL Server users
> 2. Windows users which added as a SQL Server logins/db users
> 3. Windows users which can connect to db as a members of windows groups
> added to SQL Server.
> Thnx.
>
>sql

Wednesday, March 7, 2012

How can I use the GetSchema to get a list of only user tables and views.

How can I use the GetSchema method new in 2.0 to get a list of only user tables and views.

By defautl, GetSchema will return tables that belong to dbo schema. In SQL2005, all system tables/views belong to sys schema. If you want to get schema for objects that belong to a specific user, you should set the 2nd restriction value to the owner name. For example:

string connectionString = "Data Source=(local);Database=master;Integrated Security=SSPI;";


using (SqlConnection connection =
new SqlConnection(connectionString))
{
//Connect to the database, and then retrieve the
//schema information.
connection.Open();
string[] restrictions = new string[4];
restrictions[1] = "iori";
DataTable table = connection.GetSchema("Tables", restrictions);

// Display the contents of the table.
foreach (System.Data.DataRow row in table.Rows)
{
foreach (System.Data.DataColumn col in table.Columns)
{
Console.WriteLine("{0} = {1}", col.ColumnName, row[col]);
}
Console.WriteLine("============================");
}

Console.WriteLine("Press any key to continue.");


}

For more info, please go to this website:

http://msdn2.microsoft.com/en-us/library/ms254934.aspx

|||

When I changed the string as follows to access db. I am getting the error. Please help! thanks

myConnectionString ="Provider=Microsoft.Jet.Oledb.4.0; Data Source=c:AjaxSureAcc/App_Data/AccountInfo.mdb";

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:System.ArgumentException: Keyword not supported: 'provider'.

|||

never mind the above. I figured it out. I should have been using oleDBConnection