|
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
|
|
|
|
|
Hi,
I want to change the value of text box at run time in windows application with c#.net 2005.
But,I am getting the error Cross-thread operation not valid.Can anybody tell what is the reason
|
|
|
|
|
It appears that the code that's trying to alter the textBox is running on a seperate thread. What object is trying to alter it?
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
I just want to enter the value at runtime which is coming from the serial port donot have any idea about any other object
|
|
|
|
|
show these portions of your code
1. how you create your serial port reader
2. where you get the text from the serial port and attempt to assign to the textbox's Text property.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
Serial Port Declaration :
private SerialPort comport = new SerialPort();
reponse from com port : string response = comport.ReadExisting()
Changing the value : textbox1.text = response.Substring(0, 1)
|
|
|
|
|
There's nothing using threading in the code you've posted. I assume you're using a thread to read the port, is your serial port declaration in there?
BTW, there's a simple example on MSDN[^] - it might be worth comparing to your code.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
I guess you're setting the text from within the comport_DataReceived event handler, which the SerialProt object calls from another thread. Either you read up on threading, or you don't use the event but put a timer onto your form (or control) and poll the com port from the timer's Tick event.
|
|
|
|