|
Dear Sivamyneni,
Currently i don't know the problem with DataSource, i think at a time we can add only one datasource. I also couldn't find the listbox.DataBind() and listbox.DataTextField. What version of .NET u r using.
By the Way an alternate way i am giving here and try it..
//Connection to database
OdbcConnection con = new OdbcConnection("DRIVER={MySQL ODBC 3.51 Driver};server=localhost;database=mysql;uid=root;pwd=mysql");
con.Open();
//Get data from user table
OdbcDataAdapter ad = new OdbcDataAdapter("select * from user", con);
DataSet set = new DataSet();
ad.Fill(set);
//Here is the code to add all the items of the first column of the user table.
foreach (DataRow row in set.Tables[0].Rows)
{
listBox1.Items.Add(row[set.Tables[0].Columns[0]]);
}
////ON OTHER EVENT LIKE CHECKBOX OR BUTTON CLICK REPEAT THIS.
OdbcDataAdapter ad = new OdbcDataAdapter("select * from BILL", con);
DataSet set = new DataSet();
ad.Fill(set);
//Here is the code to add all the items of the first column of the bill table.
foreach (DataRow row in set.Tables[0].Rows)
{
listBox1.Items.Add(row[set.Tables[0].Columns[0]]);
}
|
|
|
|
|
hi,
I have made a vpn connection and tested it but i want to know how to run and launch it from the code or windows scripting host.I need to make an automatic program to run this vpn in random times and close it.
|
|
|
|
|
Hi
I have written a program to zip files with Shell32 in C#.
The program zips the folders and then deletes the original folders.
The problem is that the folders are big in size ,each being atleast 10MB in size.
Now when the program starts the delete process it gives me that the folder cannot be deleted because it is being used by other process.
Now I think that the zip process is not completed and the delete process starts and hence the error.
Is there any way to know that the folders are not being used anymore and then i can proceed with the delete operation.
Or is there anything that will tell me that the zip prcess is over.
I am using the thread.sleep method but it aint helping.
Thanks,
Nikhil
|
|
|
|
|
It would probably be better to use a .NET implementation of Zip because that way you can completely control it. And find out exactly when it finishes.
Free Libraries:
#ziplib - http://www.icsharpcode.net[^]
Xacc.IDE[^] has a BZip2 implementation
Formula 1 - Short for "F1 Racing" - named after the standard "help" key in Windows, it's a sport where participants desperately search through software help files trying to find actual documentation. It's tedious and somewhat cruel, most matches ending in a draw as no participant is able to find anything helpful. - Shog9
Ed
|
|
|
|
|
HI,
I'm a new member here and am glad to be one.I'm sure I'll find vast info here
as I start to venture into learning C#. I'm currently a axapta developer which happen to use X++ language (similar to C#).
regards,
pdchua
|
|
|
|
|
|
Hi, I currently want to build the login form where the process will be:
1.User choose their membership type like free, gold, platinum (role)- bind from role db
2.User go to fill in login, pw, secret question.. page
3.User go to other page continue, finally complete
But problem faced when i want to pass the selected role type in 1st step into 2nd step, then only add role [failed to pass], since in first step, there's no username yet, so add role is failed..
I try to pass data in the same page, but failed...
Besides, how to show limited role membership in drop down box?
The application will have following role: Admin, Manager, free member, gold member, platinum member.
But when I let visitor to signup, I only want to bind the free, gold, platinum member out, not others.
Help
|
|
|
|
|
Hi,
MembersTable contains a column called TitleNumber. TitlesTable has columns called TitleNumber and TitleName.
I have a textbox that I want to show the TitlesTable.TitleName that is referenced to MembersTable.TitleNumber == TitlesTable.TitleNumber.
How do I go about achieving this.
Glen Harvy
|
|
|
|
|
Glen Harvy wrote: How do I go about achieving this.
Research DataBinding on http://msdn.microsoft.com or here on Code Project
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
led mike wrote: Research DataBinding on http://msdn.microsoft.com or here on Code Project
Posting a question here is a last resort for me.
If I could find it on the web then I would have.
Can you please also explain this to me:-
led mike wrote:
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?"
Colin Angus Mackay in the C# forum
How do you mark a question "Hey mate - if you'rve got time please help me with this" ?
Glen Harvy
|
|
|
|
|
Hi Glen, welcome to Code Project. Besides the forums there are many Articles on Code Project.
Specific to your topic on the Home Page ( Click on "All Topics" in the menu bar) There is a menu on the left side of the page. Click "General C#" which expands the menu then click "C# Database" There are like 100 Articles on ADO.NET topics some of which are beginners guides and include Data Binding. Most Articles contain sample code and even downloadable code complete with projects ready to compile and run. The MSDN site also contains Articles of a similar nature.
In case you have trouble navigating Code Project here is a link to C# Database Articles Page[^]
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
Hello,
I want to destroy an object without GC help. I read a lot of stuff how to do it, but im confused.
I realise that I must implement a Dispose metod, but I dont know how to release resources inside Dispose(bool) method. I will try to explain that into this example:
public class MyClass
{
long dolgo;
public MyClass(long lo)
{
dolgo = lo;
}
public ~MyClass()
{
Dispose(false);
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this); // Finalization is now unnecessary
}
protected virtual void Dispose(bool disposing)
{
if(!m_disposed)
{
if(disposing)
{
// Dispose managed resources
//(how to dispose it, if in this class isnt any object)
}
// Dispose unmanaged resources
}
m_disposed = true;
}
private bool m_disposed = false;
}
class Program {
static void Main (string[]args){
MyClass mc=new MyClass(thisIsAnLongValue);
//here I do stuff...........
/* and here i want to deleate this object. I realise that I must call mc.Dispose();(or something like that), but I dont know how to release resources into the Dispose(bool) method ( in every example is an object to dispose inside the object class, but I dont have it I have only a variable long).*/
}
}
will be eny diference, if there is an array like MyClass[] mc;(mc destroy==?)
Thanks
Matej
|
|
|
|
|
Hi,
first of all when you implement a Dispose method you should implement the IDisposable interface (this interface is declaring void Dispose() ).
In your case you do not need any Dipose at all. The garbage collector will do all the needed work. Dispose is primarily needed to release unmanaged or very big resources. As you only have one long field there is absolutely nothing you could release.
And have a look at rhis article[^]. Its a good introduction.
|
|
|
|
|
Hi,
thank you for the answer. I looked those article and I'm wandering how can be img object set to null after being disposed (destroyed) in the Dispose(bool) method, and where is the code for that dispose?
if (img != null)
{
img.Dispose();
img=null;
}
So if my tought is write this code "img.Dispose();" doesnt destroy the object, just free the resource he occuped? And the code for dispose an Image object in in that Image class and how does it look this piece of code? So you can't dispose an object who have the reference to a variable.
Is it always when you want to dispose an object the "final" call to an System class?
Matej
|
|
|
|
|
You have to understand that you are working within a managed environment. Calling Dispose explicitely tells the image to release its resources immediately. Nevetheless the reference to it is still there. And even if you set all references to null the object will still remain in memory until the garbage collector makes his next round and destroys it. In case of the image (and most other objects) the finalizer will call Dispose if you haven't done so before. So there is no big need to call dispose. Its just a bit cleaner and gives you more control on when the resources are freed because the garbage collector is working unregulary and unpredictable.
|
|
|
|
|
It's true that you don't need to do any disposing on this example. But if you insist you could try forcing the Garbage Collector to realease all resources that are no longer used: "GC.Collect()".
Do your best to be the best
|
|
|
|
|
Hello!!
I made a control which contains a RichTextBox and2 buttons.
One button open a text file and the other save a text file:
//---OPEN
OpenFileDialog open = new OpenFileDialog();
open.Filter = "Text files (*.txt)|*.txt";
if (open.ShowDialog() == DialogResult.OK)
richTextBox1.LoadFile(open.FileName);
//---SAVE
SaveFileDialog save = new SaveFileDialog();
save.Filter = "Text files (*.txt)|*.txt";
if (save.ShowDialog() == DialogResult.OK)
richTextBox1.saveFile(save.FileName);
And i want to host the control in Internet Explorer.
Then i create an html file:
RichTextBox Control
<object id="RichTextBoxControl1"
classid="http:RichTextBoxControl.dll#RichTextBoxControl.RichTextBoxCtl"
height="500" width="500" viewastext="">
And i Configure the Virtual Directory.
I open the html page and i can see the control but when i want to open a text file an exception appears:
System.Security.SecurityException: 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Also i configure the permissions in the .NET Framework 2.0 Configuration but the same exception appears.
Somebody knows if i am missing something.
Regards,
Alberto Martinez
|
|
|
|
|
Trust you havenot forgotton that Javascript and VBScript are unable to access your hard drive from a web page without using an Active X Control.
Please read the ENTIRE thread starting with [^]
modified 1-Aug-19 21:02pm.
|
|
|
|
|
I have Windows Control Library (derived from Control).
I wish my own custom type editor to allow the user to select something. I already made it (2 classes - one derived from System.Windows.Forms.UserControl, second from System.Drawing.Design.UITypeEditor.
In first of these I overriden OnPaint method and set Region property.
In second, I overriden:
public override System.Drawing.Design.UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)<br />
{<br />
return UITypeEditorEditStyle.DropDown;<br />
}<br />
<br />
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)<br />
{<br />
return 0;
}
In the class derived from control I set a property:
[Category("Shape"), Description("Color at center")]<br />
[BrowsableAttribute(true)]<br />
[EditorAttribute(typeof(ShapePicker), typeof(System.Drawing.Design.UITypeEditor))]<br />
public int CenterColor<br />
{<br />
get { return 3; }<br />
set<br />
{ MessageBox.Show(value.ToString()); }<br />
}<br />
}
When I create a Win Project and put this WCL on the form, all goes well, the property is shown. But when I click on that property`s ellipse (for the custrom type editor to be opened), nothing is being shown. It looks as if the EditValue method is being called immediately after opening this custrom type editor.
---------------------------------------------------------------------------------
Could you please tell me why is that? Why I canon choise anything from this custorm type editor?
thank you very much for any help
|
|
|
|
|
Sometimes (less that 1% of the calls) I am getting “System.Runtime.Remoting.RemotingException: Port is Busy: All pipe instances are busy” on remote method invocation when using IpcChannal.
Has anybody experienced the same problem?
Suggested solutions?
|
|
|
|
|
How can I display the animation on the win form like that of MSN messenger, which is displayed when we click the login button?
By simply placing an animated gif file on the win form, it starts animating, even in design mode.
But, I want to display it for some button's click event, like exactly that of MSN messenger. Any idea?
|
|
|
|
|
Use a timer, when it ticks show the "next" image in an image sequence.
:josh:
My WPF Blog[^]
|
|
|
|
|
thank you :josh: for the reply.
The messenger animation may be like what you've said. But, I have a single animated gif file, whose animation is on its own. Do u have any solution for this scenerio?
|
|
|
|
|
sinanju wrote: But, I want to display it for some button's click event, like exactly that of MSN messenger. Any idea?
They are done in Macromedia Flash.
|
|
|
|
|
Thank you leppie, for you reply.
Here how can i manage to display it, some threading will do the trick, so that i can move the form around while the animation is on?
|
|
|
|