|
hi,
when i connect to sql server give error
Error is
"Cannot open database "PENTIUMD" requested by the login. The login failed.
Login failed for user 'sa'."
i am using blow code
SqlConnection con = new SqlConnection("Data Source=(local); Initial Catalog =PENTIUMD;User ID=sa;Password=java;");
servername=pentiumd
user=sa
password=java
thanks in advance
mjawadkhatri
|
|
|
|
|
And is "pentiumd" your local machine where you run your code?
What if you change the <cdoe>Data Source=(local) to the actual IP-address?
|
|
|
|
|
(1) Check either SQL Login is enabled or not?
(2) Use the Instance name instead of (local) and check the enabled protocols for the same.
|
|
|
|
|
I want a notifier in the system tray for my c# console application.
When I will start my console application it should should notify me and will stay in the system tray. That means in the task bar like antivirus, DAP etc).
I can create it for windows application. But I need help to do it for console application...
|
|
|
|
|
Message Closed
modified 23-Nov-14 6:56am.
|
|
|
|
|
|
it is exactly the same for console app as for WinForms app.
you may have to include a few using statements (e.g. using System.Windows.Forms) which you get for free when you create a WinForms app.
|
|
|
|
|
Actually I tried it without adding the references.
Now this is working fine. thanks.
|
|
|
|
|
I am having another problem after showing the notifier in my console application. I have added context menu. But this is not showing any menu after right click in my notifier. How to solve this???
|
|
|
|
|
Hi
Can anyone provide me a sample code of RSA-SHA1 algorithm in C#?
|
|
|
|
|
|
|
OK... what is the corresponding command/code in C#
PERL
openssl genrsa -out private-key.pem 1024
Thanks
|
|
|
|
|
How can I execute a function for a huge number of users? Say 5000.
In my web application there are more then 5000 users. they all get their revenue based on the business generated by them. The problem is:
The revenue has to be generated daily. If I create a form with text box as user id and a button and on click of the button the function to generate the revenue execute, it is going to take forever for all the users as the query contains deleting, updating, inserting, and other tasks. So how can I create a function that executes for all the users.
|
|
|
|
|
you can pass the where as parameter if no user (specific user ) pass ""(nothing)
|
|
|
|
|
I think you are not getting my point. There is no issue with query. The only thing is that the administrator has to manually create commission for every user. I want this functionality automated. That means the function for creating commission should run for every member at once.
|
|
|
|
|
i think your problem how to call all users ??
if yes then the problem in your query and the solution as i replied before
if No then i am not understand your problem stell
|
|
|
|
|
If I understood well, as soon as the next day arrives your want to execute the query for all users, right?
I use some code that has this type of functionality. Effectivelly, in Global.asax I create a new thread.
That thread will then, in a while(true) (yes, an infinite loop) wait for the next day.
Something like:
DateTime now = DateTime.Now;
DateTime nextDay = now.Date.AddDays(1);
TimeSpan diff = nextDay - now;
Thread.Sleep(diff);
And then, will execute the query for every user, sequentially. This way, you will not have problems when each user calls the method, that will only read the result. The method must only be prepared to know if the SP was run or not.
You can, for example, make every user wait for the SP to run using ReaderWriterLockSlim.
For example, you create a global (static) variable for the lock.
public static ReaderWriterLockSlim GlobalLock = new ReaderWriterLockSlim();
When you run the SP that calculates the values, you do the pattern:
GlobalLock.EnterWriteLock();
try
{
// execute the SP
}
finally
{
GlobalLock.ExitWriteLock();
}
And, at each user read you do:
GlobalLock.EnterReadLock();
try
{
// execute the SP
}
finally
{
GlobalLock.ExitReadLock();
}
This way, the users will wait until the SP finish before reading (considering they are calling the method at midnight).
|
|
|
|
|
This is almost what i was looking for. Thanks. I will try and tell you. Thanks again.
|
|
|
|
|
If I have a c++ app that gets a pointer to a c++ char, will I be able to read that value into a C# char from the address from the c++ app? Or are they incompatible?
|
|
|
|
|
AFAIK IntPtr is the closest you can get through managed code. If there is a method in the dll which returns char* , try getting the return value into an IntPtr and then use it.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
I can't figure out what is wrong with my c#/c++ code trying to do this...
c# Code
try
{
char c;
string s;
int i;
i = System.Convert.ToInt32(Environment.GetCommandLineArgs()[1]);
unsafe
{
char* charp;
charp = (char*)i;
c = *charp;
}
s = c.ToString();
System.IO.File.WriteAllText("C:\\users\\name\\file.txt", System.IO.File.ReadAllText("C:\\users\\name\\file.txt") + Environment.NewLine + s);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + Environment.NewLine + ex.InnerException);
}
C++ Code that launches the above and passes the pointer to a char.
int inn = &the_char;
ShellExecute(NULL,NULL,"C:\\csharpfile.exe",inn,NULL,0);
|
|
|
|
|
I cannot figure out what your code is trying to do.
Take the first command line argument and convert it to an integer.
In an unsafe block cast the integer to a character pointer and take the first character of that array.
Convert that character to a string.
Use that string for some purpose.
Did you try running this through the debugger to see what results you are getting?
|
|
|
|
|
Hi,
I have a sdk written in c++ to control an IP module from .net. I wish to port all these libraries to C#. As i have never written interops, wrappers, or even worked in c++, what are my options. I need to know what i need to know to accomplish making dll's which are compatible to c# or if there are any third party tools that can convert all dll's from C++ to C#.
Thank you.
|
|
|
|
|
If you just need to use the methods that the dll exposes in your C# code, you need to check if the dll is managed or unmanaged. If it is a managed one, add reference to it, create object and call methods.
If it is an unmanaged dll, you can use DllImport attribute. Here[^] a link that might help you.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|