|
Sorry my bad , here the true ones:
using System;
using System.Windows.Forms;
using System.Net.Sockets;
using System.Net;
|
|
|
|
|
I have created a project using your code and I cannot get the error that you are getting.
I had to comment out one line as it gave compile errors and I could not find any reference to it despite a thorough internet search.
That line was:
new Client_sThresds(clientSocket);
so it could well be that whatever that is, is the cause of your problem.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
I wouldn't let CG touch my Abacus!
When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is.
|
|
|
|
|
It's because you don't have that class.
Just comment that line, and try to run without it.
modified on Saturday, February 12, 2011 8:24 PM
|
|
|
|
|
Marat Beiner wrote: Just comment that line, and try to run without it.
As I said in my previous post, I did.
I could not get the error that you are getting.
I can only suggest that you copy the entire error message and paste it into the search box on your favourite search engine. It may be that someone else has had the same problem and posted about it.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
I wouldn't let CG touch my Abacus!
When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is.
|
|
|
|
|
I tried it before, found nothing helpful, thanks anyway.
|
|
|
|
|
Hi everyone,
I have developed a desktop application. I have created a menu item to click for backup database from MS SQL Server 2005. This is why I have created a method to perform the operation. But the method is not working well. There’s something wrong in the code which I cannot recognize. Please help me to find the problem and solution as well. The method code is given bellow:
public void BackupDatabase(String databaseName, String destinationPath)
{
try
{
Backup sqlBackup = new Backup();
sqlBackup.Action = BackupActionType.Database;
sqlBackup.BackupSetDescription = "ArchiveDataBase:" + DateTime.Now.ToShortDateString();
sqlBackup.BackupSetName = "Archive";
sqlBackup.Database = databaseName;
BackupDeviceItem deviceItem = new BackupDeviceItem(destinationPath, DeviceType.File);
SqlConnection sqlCon = new SqlConnection(GenericDataAccess.GetConnectionString());
ServerConnection connection = new ServerConnection(sqlCon);
Server sqlServer = new Server(connection);
Database db = sqlServer.Databases[databaseName];
sqlServer.Databases.Add(db);
sqlBackup.Initialize = true;
sqlBackup.Checksum = true;
sqlBackup.ContinueAfterError = true;
sqlBackup.Devices.Add(deviceItem);
sqlBackup.Incremental = false;
sqlBackup.ExpirationDate = DateTime.Now.AddDays(3);
sqlBackup.LogTruncation = BackupTruncateLogType.Truncate;
sqlBackup.FormatMedia = false;
sqlBackup.SqlBackup(sqlServer);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
}
}
And the click event from where I am calling the method is also given:
private void backupMnuItem_Click(object sender, EventArgs e)
{
BackupData_Bl backup = new BackupData_Bl();
backup.BackupDatabase("CFM", "D:\\TEMP");
}
For your information (it might help you to find the problem) I have first create my database using SQL Server Management Studio. Then I’ve move the database from sql server installation location to my project directory under a folder named DB. After that I have attached the database using SQL Server Management Studio.
|
|
|
|
|
And the error you get is?
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
|
Please don't post this sort of thing here; this is a technical forum, let's keep it that way.
I must get a clever new signature for 2011.
|
|
|
|
|
Reported as spam in sugs&bugs: he posted the same in the Java forum as well...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
I am working in c# i want to apply the timer on the buttons or want to change their colour randomly from green to red after certain time.I dont want all the buttons to change the color from green to red at the same time i.e if there are three buttons then then they can change colour from green to red at different time periods. Is there any function to do this???
|
|
|
|
|
Subclass Button and wrap a Timer exposing the properties and methods of it that you need.
Something like this - just set ColorA , ColorB and Interval then call Start .
using System;
using System.Drawing;
using System.Windows.Forms;
public class ColoredButton : Button
{
public static readonly Color DefaultColorA = Color.Red;
public static readonly Color DefaultColorB = Color.Green;
public const int DefaultInterval = 1000;
public event EventHandler Tick;
private Color colorA;
private Color colorB;
private Timer timer;
public ColoredButton()
{
colorA = DefaultColorA;
colorB = DefaultColorB;
BackColor = colorA;
timer = new Timer();
timer.Interval = DefaultInterval;
timer.Tick += TimerTick;
}
public Color ColorA
{
get { return colorA; }
set { colorA = value; }
}
public Color ColorB
{
get { return colorB; }
set { colorB = value; }
}
public int Interval
{
get
{
if (timer != null)
return timer.Interval;
else
return DefaultInterval;
}
set
{
if (timer != null)
timer.Interval = value;
}
}
protected override void Dispose(bool disposing)
{
if (disposing && timer != null)
{
timer.Dispose();
timer = null;
}
base.Dispose(disposing);
}
protected virtual void OnTick(EventArgs e)
{
EventHandler eh = Tick;
if (eh != null)
eh(this, e);
}
public void Start()
{
if (timer != null)
timer.Start();
}
public void Stop()
{
if (timer != null)
timer.Stop();
}
private void TimerTick(object sender, EventArgs e)
{
if (BackColor == colorA)
BackColor = colorB;
else
BackColor = colorA;
OnTick(EventArgs.Empty);
}
}
|
|
|
|
|
Thanks. But where should i put this code. i have a form and have placed button on it. So i want that whenever i run the program this code should work
|
|
|
|
|
You would create a new class called ColoredButton and place this code in there.
Build the application, then replace the buttons with these - a ColoredButton control will have appear in the toolbox.
|
|
|
|
|
I have creadted a class and when build its giving errors
Here is the code
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
namespace ClassLibrary1
{
public class ColoredButton
{
public static readonly Color DefaultColorA = Color.Red;
public static readonly Color DefaultColorB = Color.Green;
public const int DefaultInterval = 1000;
public event EventHandler Tick;
private Color colorA;
private Color colorB;
private Timer timer;
public ColoredButton()
{
colorA = DefaultColorA;
colorB = DefaultColorB;
BackColor = colorA;
timer = new Timer();
timer.Interval = DefaultInterval;
timer.Tick += TimerTick;
}
public Color ColorA
{
get { return colorA; }
set { colorA = value; }
}
public Color ColorB
{
get { return colorB; }
set { colorB = value; }
}
public int Interval
{
get
{
if (timer != null)
return timer.Interval;
else
return DefaultInterval;
}
set
{
if (timer != null)
timer.Interval = value;
}
}
protected override void Dispose(bool disposing)
{
if (disposing && timer != null)
{
timer.Dispose();
timer = null;
}
base.Dispose(disposing);
}
protected virtual void OnTick(EventArgs e)
{
EventHandler eh = Tick;
if (eh != null)
eh(this, e);
}
public void Start()
{
if (timer != null)
timer.Start();
}
public void Stop()
{
if (timer != null)
timer.Stop();
}
private void TimerTick(object sender, EventArgs e)
{
if (BackColor == colorA)
BackColor = colorB;
else
BackColor = colorA;
OnTick(EventArgs.Empty);
}
}
}
Errors:
Error 1 The type or namespace name 'Drawing' does not exist in the namespace 'System' (are you missing an assembly reference?) C:\Documents and Settings\XPPRESP3\Local Settings\Application Data\Temporary Projects\ClassLibrary1\ColoredButton.cs 4 14 ClassLibrary1
Error 2 The type or namespace name 'Windows' does not exist in the namespace 'System' (are you missing an assembly reference?) C:\Documents and Settings\XPPRESP3\Local Settings\Application Data\Temporary Projects\ClassLibrary1\ColoredButton.cs 5 14 ClassLibrary1
Error 3 The type or namespace name 'Color' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\XPPRESP3\Local Settings\Application Data\Temporary Projects\ClassLibrary1\ColoredButton.cs 15 32 ClassLibrary1
|
|
|
|
|
The errors give you the answer!
In your ClassLibrary1 project, in Solution Explorer, right click on References, choose Add Reference and under the .NET tab click System.Drawing and click OK. Repeat for System.Windows.Forms.
There is no need to post the same reply twice by the way
|
|
|
|
|
Thanks a lot. A class has been successfully created but when i create a from and the colored button control does not appear in the tool box.
|
|
|
|
|
I have created the class but its giving me errors when i build the application:
here is the code
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
namespace ClassLibrary1
{
public class ColoredButton
{
public static readonly Color DefaultColorA = Color.Red;
public static readonly Color DefaultColorB = Color.Green;
public const int DefaultInterval = 1000;
public event EventHandler Tick;
private Color colorA;
private Color colorB;
private Timer timer;
public ColoredButton()
{
colorA = DefaultColorA;
colorB = DefaultColorB;
BackColor = colorA;
timer = new Timer();
timer.Interval = DefaultInterval;
timer.Tick += TimerTick;
}
public Color ColorA
{
get { return colorA; }
set { colorA = value; }
}
public Color ColorB
{
get { return colorB; }
set { colorB = value; }
}
public int Interval
{
get
{
if (timer != null)
return timer.Interval;
else
return DefaultInterval;
}
set
{
if (timer != null)
timer.Interval = value;
}
}
protected override void Dispose(bool disposing)
{
if (disposing && timer != null)
{
timer.Dispose();
timer = null;
}
base.Dispose(disposing);
}
protected virtual void OnTick(EventArgs e)
{
EventHandler eh = Tick;
if (eh != null)
eh(this, e);
}
public void Start()
{
if (timer != null)
timer.Start();
}
public void Stop()
{
if (timer != null)
timer.Stop();
}
private void TimerTick(object sender, EventArgs e)
{
if (BackColor == colorA)
BackColor = colorB;
else
BackColor = colorA;
OnTick(EventArgs.Empty);
}
}
}
Errors:
The type or namespace name 'Color' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\XPPRESP3\Local Settings\Application Data\Temporary Projects\ClassLibrary1\ColoredButton.cs 40 16 ClassLibrary1
Error 1 The type or namespace name 'Drawing' does not exist in the namespace 'System' (are you missing an assembly reference?) C:\Documents and Settings\XPPRESP3\Local Settings\Application Data\Temporary Projects\ClassLibrary1\ColoredButton.cs 4 14 ClassLibrary1
|
|
|
|
|
i m working in c#.How to insert values in text box at run time in window application and compare it with the int.can any one tell me.any help will be appreciated.
Thamks
|
|
|
|
|
Your question isn't 100% clear: are you asking how to move values from a number (say an int ) to a TextBox, and then back from a TextBox to a number again?
If so, then:
int i = 12;
double d = 12.776;
textBoxIntegerValue.Text = i.ToString();
textBoxDoubleValue.Text = d.ToString(); You can apply formatting information in the ToString method if you need to. See MSDN[^] for more info.
To go back to a number:
int i;
double d;
i = int.Parse(textBoxIntegerValue.Text);
d = double.Parse(textBoxDoubleValue.Text);
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
Thanx.But i want that how to insert values at run time in text box after debugging the program not defining a variable and inserting values in text box.Is there any function??
|
|
|
|
|
First Ur question is not appropriate
For Inserting Values into the textbox is Textbox.Text
If you can think then I Can.
|
|
|
|
|
But i want to put the values in text box after running the program.Whenever i run the program i can put any value in text box that should be assigned to any other variable.I donont want to assign the values to text box as:
Textbox.text="good";
Not like this but to insert values at run time and convert it to int and assign it to any variable,
|
|
|
|
|
if u want to assign value in textbox then use Textbox.Text
but if you want to assign value in variable then use String s = textbox.text
if u want to convert value from string to int then use Int32.Parse("string value")
Best Regard
If you can think then I Can.
|
|
|
|
|
Sorry, but that doesn't make a lot of sense to me - it is probably a language translation problem.
Could you try to explain in more detail?
Try breaking it up into stages:
"I have a TextBox on my form called textBox1"
"I want to put a value into textBox1 so I can read it"
"I want to get the value from..."
And so on?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|