|
Er nikesh yadav wrote: plz give me coding
The code will be highly dependent on the database that you use.
If it is Access then a simple file copy might suffice
If it is SQL Server the two choices I'd look at would be to restore a blank database to the location that you want, or to have a set of scripts to create a brand new database
Other database system may offer similar choices, they may offer something completely different.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
|
Then you probably just want to copy the file. See the FileInfo class.
See: MSDN - FileInfo[^]
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
Hello All,
I am trying to bind the listbox to a column of the datatable. If i try directly on the click of the button then it will display the data. but, if i am trying to do this by creating a thread for this process it is doing nothing, no error is shown. Please help me.
Thanks in advance.
Bharath.S Ron
|
|
|
|
|
I think an exception IS thrown however you catch it on some place. You cannot change GUI related things on a diffrent thread.
Try creating a delegate and call the delegate from your diffrent thread using Invoke()
for example :
<br />
private delegate void doBindListbox();<br />
private void BindListbox()<br />
{<br />
}<br />
and call the delegate from your diffrent thread like so :
<br />
this.Invoke(new doBindListbox(BindListbox));<br />
|
|
|
|
|
Hi,
Is this the correct way?
trd = new Thread(new ThreadStart(this.Invoke(new delegateloaddata(loaddata))));
delegateloaddata = delegate.
loaddata = is the method which has to be called through thread
Bharath.S Ron
|
|
|
|
|
No, it's not...
<br />
private void StartMyThread()<br />
{<br />
ThreadStart ts = new ThreadStart(InvokeBinding);<br />
Thread th = new Thread(ts);<br />
th.Start();<br />
}<br />
<br />
private void InvokeBinding()<br />
{<br />
this.Invoke(new doBindListbox(BindListbox));<br />
}<br />
See the example in my previous post....
|
|
|
|
|
Thank you.
I tried that method it is working and loading the data into the listbox but, it is not working as a thread. I cannot stop it in between.
Bharath.S Ron
|
|
|
|
|
What do you mean with :
Bharath.S.Ron wrote: I cannot stop it in between.
|
|
|
|
|
Hi,
AS i am trying to impliment that as a thread , i want to stop it in between as well.
stop in the sense, the form should not freeze while performing that function, i should be able to click other buttons as well while this is being doing its job.
Bharath.S Ron
|
|
|
|
|
this is the code which i am using.
public void loaddata()
{
try
{
conn = new SqlConnection("Data Source=local; Initial Catalog=Northwind; User ID=sa; Password=; Persist Security Info =True;");
adpt = new SqlDataAdapter("Select * from Categories", conn);
ds = new DataSet();
adpt.Fill(ds);
listBox1.DataSource = ds.Tables[0];
//trd
listBox1.DisplayMember = "CategoryName";
Thread.Sleep(1000);
//trd.Start();
}
catch (SqlException ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
on click of the button i am calling that thread.
private void btnStart_Click(object sender, EventArgs e)
{
try
{
// this is wokring
ThreadStart myThreadDelegate = new ThreadStart(loaddata);
trd = new Thread(myThreadDelegate);
trd.Start();
trd.IsBackground = true;
// till here
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
this below code is to stop the thread.
private void btnStop_Click(object sender, EventArgs e)
{
//Thread trd = new Thread(new ThreadStart(this.loaddata));
//trd.Abort();
try
{
if ((trd.ThreadState == ThreadState.Running )|| (trd.ThreadState==ThreadState.Background))
{
trd.Abort();
}
}
catch (ThreadStateException Ex)
{
MessageBox.Show(Ex.ToString(), "Exception",
MessageBoxButtons.OK, MessageBoxIcon.Error,
MessageBoxDefaultButton.Button1);
}
}
please help me..
Bharath.S Ron
|
|
|
|
|
Hi,
I Have Some Problem how can we bind data into tab control..for example:
i have a table name Working, in first column i have field name "Id" for primary key and i make it autoincrement, and in the second column i have field name Status..what makes me confuse if on field status have 2 value :"typing, printing"..how can i make tab control have 2 tabPages name "typing" and "printing"
Please Help me coz i'm new in C#...
Thanks and Regard,
TCim
|
|
|
|
|
I'm getting the following error:
Project FooBar could not be opened because the Microsoft Visual C# .NET compiler could not be created.
I reinstalled VS as recommended by the next line of the error message and it all worked fine.
This morning i open VS and guess what, I get the message again. Reinstalling took me hours yesterday and reduced my PC to a uselesss whirring mess for most of that time. It did however fix the problem for the last few hours of the day.
The suggestions i see on the web are that this problem is due to having a pathname over 260 characters in the project but i've moved my project folder to c and it stil doesn't open.
Has anyone else suffered this problem and found a fix?
Thanks
Russell
|
|
|
|
|
|
yeah,
strangely One of the guys found a solution suggested by ReSharper. I installed Resharper thinking it might tell me what was wrong. When I opened the project my cursor changed to a biohazard symbol with a green arrow and magically my project now works.
Who knows what was up with it, I hope I'm not back here tomorrow having suffered the same problem when i turn my PC on in the morning.
Russell
|
|
|
|
|
wow! it might be worth going over to the resharper forums and asking if they've done a fix for the issue
|
|
|
|
|
I'm working on a project on controlling the printer using C#. Such as restrict printing, counting no of pages.
I need references...
and I like to share ideas, if you have worked on that kind of project.
Any ideas? any links you know?
Thanks.
Chatura Dilan
|
|
|
|
|
Hi,
I want to change the color of Panel when i drag the mouse, that is color should be changed only where am dragging rest of the area should be as it is.
I have mouse position as like below
temp.X = e.X ;
temp.Y = e.Y ;
mMousePos = this.panel1.PointToScreen (temp);
I want to set the color for the area btw e.X and e.Y
|
|
|
|
|
Hello,
I think it's best to create an image for your panel and get a Graphics object from that.
With this Graphics object you than can do a lot of fancy stuff.
Here is an example with an panel and MouseMove event:
private Graphics panelGraphics = null;
private Pen panelPen = null;
private Point oldPosition;
private bool init=false;
private void panel2_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if(panel2.BackgroundImage==null)
{
panel2.BackgroundImage= new Bitmap(panel2.Width, panel2.Height);
}
if(panelGraphics==null)
panelGraphics = Graphics.FromImage(panel2.BackgroundImage);
if(panelPen==null)
panelPen= new Pen(Color.Red,2);
if(init)
{
Point newPostion = new Point(e.X,e.Y);
panelGraphics.DrawLine(panelPen, oldPosition, newPostion);
Refresh();
}
else
init=true;
oldPosition = new Point(e.X,e.Y);
}
Hope it helps!
Note: I instanciated the Graphics and Pen objevt only once, but you have to dispose them in your forms Dispose method.
panelGraphics.Dispose();
panelPen.Dispose();
All the best,
Martin
|
|
|
|
|
Hi,
I'm reading a file using the stream reader into a string, and the character £ which is in the file appears as a sqare box in the string, which I assume means it is unrecognised.
I'd be grateful if someoone can tell me how to get round this.
Sean
|
|
|
|
|
If the file is not encoded using UTF-8, you have to specify the encoding when creating the stream reader.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hello, I have one problem in serializing a class using .NET Serialization
for example, I have got something like this :
<br />
class Parking<br />
{<br />
public List<Vehicle> vehicles<br />
public Parking() { }<br />
<br />
<br />
}<br />
<br />
class Vehicle <br />
{<br />
<br />
}<br />
<br />
class Truck:Vehicle<br />
{<br />
<br />
}<br />
<br />
class Car:Vehicle<br />
{<br />
<br />
}<br />
<br />
class Motorbike:Vehicle<br />
{<br />
<br />
}<br />
I have been trying to serialize a 'Parking' object and the better I got was :
<br />
<parking><br />
<Vehicles><br />
<Car> .... </Car><br />
<Car> .... </Car><br />
<Truck> .... </Truck><br />
<Car> .... </Car<br />
<Truck> .... </Truck><br />
<Motorbike> .... </Motorbike><br />
.....<br />
</Vehicles><br />
</parking>
But my aim is to get this type of XML string (no 'Vehicles' node):
<br />
<parking><br />
<Car> .... </Car><br />
<Car> .... </Car><br />
<Truck> .... </Truck><br />
<Car> .... </Car<br />
<Truck> .... </Truck><br />
<Motorbike> .... </Motorbike><br />
.....<br />
</parking><br />
Have you got any idea to obtain this result ?
Thank you for your help !
jpeg
|
|
|
|
|
You can ignore object from being xml serialized using the XmlIgnore attribute
<br />
[XmlIgnore()]<br />
public List vehicles<br />
|
|
|
|
|
Thank you Eduard for your answer but my problem is not to exclude the list.
The class Parking only contain a List<Vehicle> called 'Vehicles'.
the problem is that I get :
<parking><br />
<vehicles><br />
.... all vehicules (classes Car, Truck, Motorbike ...)<br />
</vehicles><br />
</parking><br />
I only want the 'vehicles' tags to disappear and 'Car', 'Motorbike' or 'Truck' vehicles to inside the 'parking' tags.
With your solution, I get :
</parking> (the content of the 'Vehicles' list is not serialized)
jpeg
|
|
|
|
|
Hello,
I don't think that you could deserialze it correctly once it was modified this way.
And I also don't think there is a way to serialize it the way you want it.
All the best,
Martin
|
|
|
|