|
.S.Rod. wrote:
That's why I have said that's up to you to use a ADO.NET dataset as a container for the query result.
OIC what you are saying.
Thanks man, that makes sense. I still have to get into the whole DataSet way of thinking
.S.Rod. wrote:
Of course, the usefulness of sqldmo is questionable, since ADO.NET provides the .NET SQLServer data provider, which does the same job than sqldmo.
Serious? I will look into that then. Would far rather use ADO.NET to get the structure of a SQL Server and it's databases than having to do COM interop on SQLDMO. Hopefully ADO.NET can provide a list of registered SQL servers as well, like SQLDMO does.
Thanks for the help
Paul Watson Bluegrass Cape Town, South Africa NOPcode wrote:
...but in America, you're not allowed to thrust, moan or see anything...
|
|
|
|
|
To get the list of SQL servers on NT/2000/XP, use the code from the Server Enumerator[^] article. If you can see multiple domains, you'll need to enumerate the domains, and then enumerate the SQL servers for each domain. I've got some simple code to enumerate each domain in a new thread, if you want it.
Once you choose the server, you can connect to the master database, and execute SELECT name FROM master.dbo.sysdatabases ORDER BY name to get the list of databases. You could also use sp_databases , but that seems to be slightly slower.
To get the list of tables, connect to the database and execute sp_tables @table_type = "'TABLE'" . (Note the extra quotes around the parameter value.) The important column of the results is TABLE_NAME .
To get the columns of the table, use sp_columns 'Table name' . COLUMN_NAME , PRECISION , LENGTH , SCALE and NULLABLE are all fairly obvious. The TYPE_NAME will give you the name of the datatype for the column, or you can map the SS_DATA_TYPE column to the types defined in srv.h in the Tools\DevTools\Include directory of your SQL Server installation. NB: Watch out for identity columns, with a TYPE_NAME of "int identity".
You can get details of the primary key for the table using sp_pkeys 'Table name' , which will return the list of columns (COLUMN_NAME ) in the primary key for that table.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
Thanks for all the info and I did consider using the built in SPs and tables... The thing though is I like the strongy typed way of SQLDMO. The collections are all enumerable to which makes working with them easier. Using the above is a bit more finicky IMO.
I might then use your way just for the Columns... or I may switch to using ADO.NET and loose SQLDMO all together.
I wonder when SQLDMO.NET from MS is coming out
Paul Watson Bluegrass Cape Town, South Africa NOPcode wrote:
...but in America, you're not allowed to thrust, moan or see anything...
|
|
|
|
|
I'm surprised it's not out already.
I've thrown together a basic read-only library to get the information in a sensible form. I haven't done much testing, and there may be glaring holes in it, but it seems to work on my machine. If I get time, I may tidy it up a bit and upload it as an article.
If you want to try it out, and don't mind dealing with the bugs that are bound to have crept in , let me know and I'll send you the code.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
Hello,
I would like to replace standard runtime error box that displays when an unhandled exception occurs. The new standard error box should contain general unhandled error message along with the option to the user to express the circumstances of the error and send this information directly to our issue management system.
I know there is an AppDomain object that has UnhandledException event. I tried to bind a procedure to this event using AddHandler keyword. Actually I did the same what could be seen as the example in the MSDN library.
Unfortunatelly I found that this is not the way to go. The system default error message box is shown prior to mine. In addition, no all exceptions were catched by this error event handler in compiled application, although they were catched when the application was started from whithin IDE.
Does anybody any idea how to achieve desired functionality?
Thanks for any suggestions.
Vasek
Vasek
VB6, C#, MS DNA, MS .NET software developer
|
|
|
|
|
You don't indicate if this is a web app, a fat client, a component, etc.
Assuming this is a fat client: the only way I can think of how to do this is to write a wrapper application that would be the starting point for all of your executions. It would be passed the name of the application to execute.
Then you would do a TRY and use reflection to load and execute the application. Your CATCH would trap all uncaught errors and you can handle the display of the error.
Of course, a simpler way is to just catch all of your errors.
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
theRealCondor wrote:
You don't indicate if this is a web app, a fat client, a component, etc.
It is a fat windows client.
theRealCondor wrote:
Of course, a simpler way is to just catch all of your errors.
I thought there is a simple way how to handle those errors they are left uncought. No way I advocate for not handling errors.
Anyway, thanks for your response
Vasek
VB6, C#, MS DNA, MS .NET software developer
|
|
|
|
|
.NET magazine just did an article on how to do this. Do a google search for "Visual Studio Magazine - Hot .NET Tips - Catch All Exceptions in One Place"
|
|
|
|
|
I have an existing C# program which displays a form and then runs a worker thread that does some work. I have arranged for the form data to be stored within the Registry and restored when it gets run again.
What I would like to do is convert this fairly generic program to have the following features:
1. Check box that enables a NotifyIcon (Remove from Taskbar).
2. NotifyIcon that has a contextMenu that can show the form again.
(context menu has "Show Me" and "Exit" options)
I've read the tutorials on this site on creating NotifyIcon elements. However, I am not sure how to implement the above. Can someone provide some information?
-Adrian
|
|
|
|
|
You need to add a NotifyIcon to your form and to attach a ContextMenu to it.
|
|
|
|
|
I have a legacy COM In-Proccess server, which has an interface
function:
STDMETHODIMP CMyObj::GetData( /*[out]*/ DataStruct* pData )
{
...
}
where DataStruct is defined:
typedef struct AnotherStruct
{
long ID[4];
BSTR Name;
}AnotherStruct;
typedef struct DataStruct
{
AnotherStruct ArrayStruct[4];
long ArrayLong[4];
}DataStruct;
now, when i'm calling this function from the .NET (C# for the matter)
MYOBJECTLib.MyObjectClass obj = new MYOBJECTLib.MyObjectClass();
MYOBJECTLib.DataStruct data;
obj.GetData( out data );
i get an exception: "Not enough storage is available to complete this
operation.", where the source of the exception was the interop.
I tried to look at the data struct and i found out that the C#
compiler, or the interop ( i don't know which one is responsible for
it ) ,that each primitve array in the struct was initialize
automaticly to the size that was defined in the COM typelib( for
example the ArrayLong was initialized to 4 int ) , but the array of
the struct ( ArrayStruct) was set to null.
I tried to modify the code to initialize it myself:
MYOBJECTLib.MyObjectClass obj = new MYOBJECTLib.MyObjectClass();
MYOBJECTLib.DataStruct data;
data.ArrauStruct = new MYOBJECTLib.AnotherStruct[4];
obj.GetData( out data );
but it didn't work.
worth mentioning that when i modified the struct:
typedef struct DataStruct
{
AnotherStruct ArrayStruct;//ArrayStruct[4]
long ArrayLong[4];
}DataStruct;
everything worked ok.
anybody???
Amir Harel
|
|
|
|
|
I guess it's about time to do struct marshaling yourself[^].
|
|
|
|
|
my main application had started a process X and i want my application to be notified when that process had been terminated externally by OS.
i try:
X.EnableRaisingEvents = true;
but what is the event method declaration for my main application's to handle exit event triggered by process X?
thank you.
regards
yccheok
|
|
|
|
|
I'm not sure if you are looking for a event notification, in case you just want to wait until the process is over, you can try WaitForExit method on the Process class.
Cheers
Kannan
|
|
|
|
|
actually, i want two process can be run at the same time. it seems that Richard_D had provided me the solution will test it out 2night.
anyway, thanks for the suggestion.
regards
yccheok
|
|
|
|
|
Assuming X is a System.Diagnostics.Process variable:
...
X.EnableRaisingEvents = true;
X.Exited += new EventHandler(ProcessExited);
...
void ProcessExited(object sender, EventArgs e)
{
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
the follwing code compiled no problem and i make an conclusion that WMEncoder is a class instead of an interface.
WMEncoder e = new WMEncoder();//Yahoo!No problem at all!
when i try to make a derived class from WMEncoder (this is because i want to call the Finalize method explicitly):
-----------------------------------------------------------
using System;
using WMEncoderLib;
namespace GOWatch
{
///
/// Summary description for WMEncoderEX.
///
public class WMEncoderEX : WMEncoder
{
public WMEncoderEX()
{
//
// TODO: Add constructor logic here
//
}
}
}
-----------------------------------------------------------
i get 95 lines of similar error
d:\documents and settings\administrator\my documents\visual studio projects\gowatch\wmencoderex.cs(9,15): error CS0535: 'GOWatch.WMEncoderEX' does not implement interface member 'WMEncoderLib.IWMEncoder2.SetLocaleID(int)'
isn't that WMEncoder is already a class instead of interface? why i am still forced to implement interface WMEncoderLib.IWMEncoder2 members?
thank you.
regards
yccheok
|
|
|
|
|
yccheok wrote:
the follwing code compiled no problem and i make an conclusion that WMEncoder is a class instead of an interface.
WMEncoder e = new WMEncoder();//Yahoo!No problem at all!
This is one of my problems with C#, or at least it's compiler, while this may be a valid statement when dealing with C++, C# allow value types to make this same declaration, for example:
<font color="green">
struct Val
{
int X;
}
<font color="green">
Val v = new Val();
<font color="green">
Console.Write(v.X.ToString());
I really don't know about WMEncoder , however you may be dealing with something else.
Nick Parker
Not everything that can be counted counts, and not everything that counts can be counted. - Albert Einstein
|
|
|
|
|
Ok, I'm not sure of this could be the problem, but may be you would have to implement a set of interfaces on your derived class (by simply calling the base class methods or with your own implementation).
Cheers
Kannan
|
|
|
|
|
simple question for the jedi -
I always thought that protected internal combined the access modifiers into protected (only in inheritance heirarchy) and internal (only in project).
Apparently it is an either-or however: protected internal means both inheritance heirarchy or within project.
My question is *why*. Can anyone think of a good example where this might be useful?
Thanks in advance -
*->>Always working on my game, teach me
*->>something new.
cout << "dav1d\n";
|
|
|
|
|
The difference:
internal
Accessible only by methods in the defining assembly.
protected internal
Accessible only by the methods in this type, any derived type, or any type defined in the defining assembly.
This is directly from Applied .NET Framework Programming by Jeffery Richter, essentially protected internal give you more latititude when creating assemblies that provide extensibility through inheritance.
Nick Parker
Not everything that can be counted counts, and not everything that counts can be counted. - Albert Einstein
|
|
|
|
|
I've been trying to teach myself C# and web related programming with the beta version of Microsoft Visual Studio 7.0. I've tried to use the web controls but when I try and execute a simple example, the control does not appear in the browser (labels show up but buttons, etc do not). Any suggestions? I have a feeling it's a configuration problem (with IIS, browser, or something else).
Any help or suggestions appreciated.
Joe
|
|
|
|
|
Are you remembering to include the runat="server" attribute? in the asp:Button tag?
|
|
|
|
|
It shows runat="server" in the HTML section. Is there another location that this needs to go?
Any other thoughts?
Joe
|
|
|
|
|
who to get window directory path programatically?
r00d0034@yahoo.com
|
|
|
|