|
Chazzysb wrote: There was a problem in the constructor of the control!
Lucky those are easy to track down. Try throwing an exception in a static constructor, then you will be lost for a while
|
|
|
|
|
Hi everyone!
How do I convert a Bitmap var to an Image type?
System.Drawing.Bitmap myBmp;
System.Windows.Controls.Image myImg;
myImg = (Image)myBmp;
'System.Drawing.Bitmap' to 'System.Windows.Controls.Image'.
I'm really struggling to get this done, and it really seemed so easy and straight-forward but, I can't do it.
Any help will be appreciated.
Thanks a million.
|
|
|
|
|
The System.Drawing.Bitmap class inherits from the System.Drawing.Image class. All you have to do is a simple type cast.
There is no System.Windows.Controls.Image maybe you mean System.Windows.Forms.PictureBox . In that case, you'll set the Image property of it.
myPicBox.Image = myBmb;
Eslam Afifi
|
|
|
|
|
Eslam Afifi wrote: There is no System.Windows.Controls.Image
There is in WPF I think
|
|
|
|
|
Yes, there is.
It's WPF type, vectorial image stuff.
I had to use ImageSource to solve this problem, it is really a pain in the neck though.
Thanks guys.
|
|
|
|
|
Yeah, you're right. I didn't think of that. Thanks
I think he'll save the bitmap to a MemoryStream and then use the StreamSource.
Edit: I see he/she knew that already.
Eslam Afifi
|
|
|
|
|
I have disabled the control box in my properties pane on my windows form and wanted to make a cutomized button that would minimize my window. Can anyone tell how to do that?
|
|
|
|
|
this.WindowState = FormWindowState.Minimized;
Eslam Afifi
|
|
|
|
|
oh silly me! thanks!
|
|
|
|
|
You're welcome
Eslam Afifi
|
|
|
|
|
i develpoed a simple concurrent server . when startserver button is clicked the application blocks in socket.accept();
when a client is connected a new thread is created and the client is handled by that.
but then the server application again blocks in accept(). and the form is displayed as a white box,no componenets are displayed.
how can i over come this problem,i want to display the components as usual while the server is blocked in accept();
|
|
|
|
|
Accept() in another thread.
|
|
|
|
|
Hello All
i am wondering how to call a batch of SQL server scripts from inside a C# code
Thanx for your help
|
|
|
|
|
|
You can use the SqlConnection and SqlCommand in the System.Data.SqlClient namespace.
Or you can use the ServerConnection in the Microsoft.SqlServer.Management.Common namespace (reference the Microsoft.SqlServer.ConnectionInfo assembly).
Eslam Afifi
|
|
|
|
|
You can use SqlCommand class to execute commands against sql database.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
i tried that when i wrote the 1st version of my "execute SQL scripts" app, it didn't work, although i thought i would
check my other post to see what i ended up doing
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111
|
|
|
|
|
Thanks for the info.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
your welcome
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111
|
|
|
|
|
i wrote a program a while back to run all my sql scripts for me, and its FORCES the db to drop connections aswell(this is for dev purposes only)
it uses SQLCMD.exe, and you need sql2005 for that... heres the code if your interested
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Threading;
using System.IO;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Smo.Wmi;
using Microsoft.SqlServer.Management.Common;
namespace CreateDB
{
public class Program
{
public static string database;
public static string userName;
public static string password;
static void Main(string[] args)
{
getVariables();
FileStream fs = new FileStream(@"C:\scripts.txt", FileMode.Open, FileAccess.Read);
StreamReader sr = new StreamReader(fs);
killDatabase();
string line = sr.ReadLine();
while (line != null)
{
ProcessStartInfo StartInfo = new ProcessStartInfo("sqlcmd", "-S " + database + " -d master" + " -U " + userName + " -P " + password + " -i " + line);
Process myProcess = new Process();
StartInfo.UseShellExecute = false;
StartInfo.RedirectStandardOutput = true;
myProcess.StartInfo = StartInfo;
myProcess.Start();
Console.Write("Started Process --> ");
myProcess.WaitForExit();
StreamReader outputReader = myProcess.StandardOutput;
Console.WriteLine("Finnished Process ---> output:" + "\r\n");
Console.WriteLine(outputReader.ReadToEnd());
Console.WriteLine();
Console.WriteLine("|------------------------------------------------------------------------------|");
Console.WriteLine();
line = sr.ReadLine();
}
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("DDDD OOOO N N EEEEEE ");
Console.WriteLine("D D O O NN N E ");
Console.WriteLine("D D O O N N N EEE ");
Console.WriteLine("D D O O N N N EEE ");
Console.WriteLine("D D O O N NN E ");
Console.WriteLine("DDDD OOOO N N EEEEEE ");
Console.ResetColor();
Console.Read();
}
private static void getVariables()
{
Console.Write("Please Enter DataBase Name: ---> ");
database = Console.ReadLine();
Console.Write("User Name ---------------------> ");
userName = Console.ReadLine();
Console.Write("Password ----------------------> ");
password = Console.ReadLine();
Console.Clear();
}
private static void killDatabase()
{
try
{
Server srv = new Server(database);
srv.KillDatabase("uniclox_db");
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(ex.Message);
Console.ResetColor();
}
}
}
}
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111
|
|
|
|
|
Thanks Harvey, this is exactly what i was looking for.
|
|
|
|
|
Glad to help bud,
let me know if you have any troubles with it
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111
|
|
|
|
|
i have an issue in running my script
for each line in the script
i got this a message like this
Started Process --> Sqlcmd: ')': Invalid filename.
Finnished Process ---> output:
!!!
|
|
|
|
|
can you post what you have in scripts.txt ... and is that file located on the C:\ drive?
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111
|
|
|
|
|
i had sent you the script through mail, yes the script lie on the C:\ partition
|
|
|
|