|
How can i check if a database exists on an instance of SQL Server?
|
|
|
|
|
Open a connection to the master database on the SQL Server and using the following SQL (or similar)
SELECT name FROM sysdatabases This will return the names of all the databases on the SQL Server.
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|
|
Hi there,
Well, I am facing some problems while loading an assembly dynamically from a subdirectory located in ApplicationBase. The code works just fine when this dll is located in the application directory but when I tried to load it from one of the application's subdirectory it is not working even when I tried following options:
First, I created a "test" subdirectory for my test.dll(As far as my understanding of deploying a private assembly goes I believe runtime locates dll in application directory then it looks for a subdirectory having dll's name e.g. temp in this case and finally it goes to GAC.)
Second, I get following error log from fusion
LOG: Private path hint found in configuration file: test.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
where test is the subdirectory I am putting this dll.
I have included in app.config but it doesn't seem to work.
Also I have tried to use tags and made this assembly strong named and unfortunately that didn't work either.
Additionally, I have tried both LoadFrom() and Load() methods but no help.
As far as my understanding goes I think I do not need to create a strong named assembly when I am using probing element in config.
Any suggestions would be greatly appreciated.
Thanks in advance.
-Subby
|
|
|
|
|
How can i make a FlateStyle.System Button show image near the button text?
Mohamad Gamal
|
|
|
|
|
The following links should be helpful to u.
http://www.dotnet247.com/247reference/msgs/42/212760.aspx
http://www.dotnet247.com/247reference/a.aspx?u=http://www.codeproject.com/cs/miscctrl/xp-style_button.asp
Regards,
Pramod
|
|
|
|
|
Thanks for your help but,
this link show a XP Style button witch give a button a stable style and not changed with the windows button style,
i am looking for a button with image and with the currunt user windows style.
Mohamad Gamal
|
|
|
|
|
hi all
I looking for a code in C# that
chake 2 files in c# or more.
chake if bean any copy between them or not
tanks alot
it's very importent to me!
|
|
|
|
|
I hope to carry out the Cell as ( MoneyCell)
DEMO
DEMO
How to do it with the DataGridViewCell?
Thanks.
-- modified at 6:15 Monday 17th April, 2006
|
|
|
|
|
Hi,
I'm trying to typecast a class that I load from a dll. This class is using a certain interface and I'd like to type-cast it into the same interface (see code).
I should also point out that the main class and the class that I'm trying to load into it are in two seperate projects (and namespaces).
But my problem is that when I run this I get the error:
"Unable to cast object 'Class1' to type 'IPlugin'."
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
<br />
class Class1 : IPlugin<br />
{<br />
public Class1() { }<br />
<br />
public String getInfo()<br />
{<br />
return "weeee";<br />
}<br />
<br />
}<br />
<br />
public interface IPlugin<br />
{<br />
String getInfo();<br />
}<br />
<br />
<br />
namespace DLL_LoadTest<br />
{<br />
class Program<br />
{<br />
static void Main(string[] args)<br />
{<br />
Assembly assembly = Assembly.LoadFrom(@"C:\Test\ClassLibrary1\bin\Debug\ClassLibrary1.dll");<br />
<br />
IPlugin plugin = null;<br />
plugin = (IPlugin)assembly.CreateInstance("Class1");<br />
}<br />
}<br />
}<br />
please help!
thanks,
HHG
-- modified at 10:21 Sunday 26th March, 2006
|
|
|
|
|
Do you cast it into the actual interface that the class uses, or have you just created an interface with the same name in your code?
---
b { font-weight: normal; }
|
|
|
|
|
Uhm.. yes .. well.. yeah, I was using two interfaces (one in each project) both with the same name.
Once I referenced to the other one everything started to work
Thanks for the help, I just love it when the solution is too simple :P
|
|
|
|
|
If I was writing a program and wanted to trap 'all' the errors in the program, would I have put try-catch blocks 'everywhere' in my code? Is that the only way to do it? It's better to gracefully exit the program displaying the reason for the crash to the user, rather than having a .Net framework message popup with some mumbo jumbo.
|
|
|
|
|
Put try-catch blocks around the code where you anticipate errors, like database calls, file handling, and other stuff that rely on external resources. Catch the Application.TreadException exception to handle any unforseen errors.
---
b { font-weight: normal; }
|
|
|
|
|
I've never used Application.ThreadException . How do I use it? Any quickie examples?
|
|
|
|
|
Hello,
I am using C# to call a javascript function.
The original c# code is :
private const string AttachContextMenu = "return __showContextMenu({0});"; //this is the string which represents the javascript function
//then I use string.format on the string constant
public string GetMenuReference()
{
return String.Format(AttachContextMenu, Controls[0].ClientID);
}
//finally, the javascript is called upon the 'oncontextmenu' event
ctl1.Attributes["oncontextmenu"] = GetMenuReference();
But when I changed the GetMenuReference() method to the following,
return String.Format("return _showContextMenu({0});",Controls[0].ClientID);
the javascript function does not work anymore!! All I did was to replace the const variable with the actual string itself. How come it doesnt work already?
|
|
|
|
|
Because you are calling a function that does not exist. Replace "_showContextMenu" with "__showContextMenu".
---
b { font-weight: normal; }
|
|
|
|
|
hi,
Both functions above (_showContextMenu) are the same
Is there a typo?
|
|
|
|
|
return __showContextMenu({0}
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
No, they are not the same. Look again.
Tip: Count the number of underscore characters in the beginning of the name.
---
b { font-weight: normal; }
|
|
|
|
|
HI!
I have a sql script file(myscript.sql size 60k) When i run this script in a query analyzer it runs fine but when i makes its a Stored procedure so as i may be able to call it from my C# application. But sql doesnt allow me to amke a sp of it as it raises a lot of errors. Whats the real problem. I want to make this script a Stored Procedure so as i may be able to call it from my Application. Whats he solution to it. Should i be to remove all go Statements or anything else in sql Script.Or is there any other way round to do this. Solution required
THNX In Advance
|
|
|
|
|
majidbhutta wrote: I want to make this script a Stored Procedure so as i may be able to call it from my Application
You don't have to make a SQL Script a Stored procedure in order to run if from a C# application. Any SQL can be put in the CommandText propery of a SqlCommand .
majidbhutta wrote: Should i be to remove all go Statements or anything else in sql Script.
The GO is not SQL. It is a pre-processor command to Query Analyzer to tell it where to split the script into batches.
When Query Analyzer encounters a GO while processing CREATE PROCEDURE statment it treats it as the end of the stored procedure. Everything after the GO will be in a new batch and not the stored procedure - That is likely to be the cause of the error.
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|
|
I'm using NUnit to test my application but it is giving me odd error messages that I have not seen before. I'm at a loss to think what configuration change I have made that would break NUnit. (Or what configuration changes I made at all) The application is new, so these are new unit tests fixtures. I also upgraded to NUnit 2.2.7 in case there was a problem with the previous version (no luck). My application runs okay if I launch it, yet I cannot test it.
Here is the message produced by using the NUnit console through TestDriven.NET:
------ Test started: Assembly: NOsm.Dao.Testing.dll ------<br />
<br />
TestCase 'M:NOsm.Dao.Testing.BookmarkDaoTest.SimpleTest'<br />
failed: Could not load file or assembly 'NOsm.Dao.Testing' or one of its dependencies. An attempt was made to load a program with an incorrect format.<br />
System.BadImageFormatException: Could not load file or assembly 'NOsm.Dao.Testing' or one of its dependencies. An attempt was made to load a program with an incorrect format.<br />
File name: 'NOsm.Dao.Testing'<br />
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)<br />
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)<br />
at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)<br />
at System.Reflection.Assembly.Load(String assemblyString)<br />
at TestDriven.TestRunner.AdaptorTestRunner.Run(ITestListener testListener, ITraceListener traceListener, String assemblyPath, String testPath)<br />
at TestDriven.TestRunner.ThreadTestRunner.Runner.Run()<br />
<br />
WRN: Assembly binding logging is turned OFF.<br />
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.<br />
Note: There is some performance penalty associated with assembly bind failure logging.<br />
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].<br />
<br />
<br />
<br />
0 passed, 1 failed, 0 skipped, took 0.89 seconds.
The code for SimpleTest is:
[Test]
public void SimpleTest()
{
Assert.IsFalse(true);
}
If I use the NUnit GUI I get a slightly different exception:
System.IO.FileNotFoundException...<br />
<br />
Server stack trace: <br />
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)<br />
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)<br />
at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)<br />
at System.AppDomain.Load(String assemblyString)<br />
at NUnit.Core.Builders.TestAssemblyBuilder.Load(String assemblyName)<br />
at NUnit.Core.Builders.TestAssemblyBuilder.Build()<br />
at NUnit.Core.Builders.TestAssemblyBuilder.Build(String testName)<br />
at NUnit.Core.TestSuiteBuilder.Build(String assemblyName, String testName)<br />
at NUnit.Core.SimpleTestRunner.Load(String assemblyName, String testName)<br />
at NUnit.Core.SimpleTestRunner.Load(String assemblyName)<br />
at NUnit.Core.ProxyTestRunner.Load(String assemblyName)<br />
at NUnit.Core.ProxyTestRunner.Load(String assemblyName)<br />
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)<br />
at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)<br />
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)<br />
<br />
Exception rethrown at [0]: <br />
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)<br />
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)<br />
at NUnit.Core.TestRunner.Load(String assemblyName)<br />
at NUnit.Util.TestDomain.Load(String assemblyFileName, String testFixture)<br />
at NUnit.Util.TestLoader.LoadTest(String testName)
Any help would be appreciated.
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
-- modified at 8:06 Sunday 26th March, 2006
|
|
|
|
|
Okay - I've tracked down the problem. Somehow or another the project properties for the testing assembly were set to build for a 64-bit platform. I'm not sure how that happened - but it's fixed now.
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|
|
Has anyone come across a Grid Computing project in .NET? I scoured the Internet but couldn't find anything much?
|
|
|
|
|
Funny, I find quite some on a simple search like this[^]...
---
b { font-weight: normal; }
|
|
|
|