|
I have a problem
I'm busy writing a C#.NET project but walked into a problem.
I've got a Form With 3 Textboxes a Button and a DataGrid.
If i typ a value into the textboxes and i press the button. The datagrid Shows me the correct data.
the Selectcommand:
Select colom1, colum2, colom3, colom4, colom5
From Tabel1
Where (Colom1 = :param2)
and (Colom2 = :param3)
and (Colom3 = :param4)
But now i want it like This:
If i Typ a value for the first and last colom and nog the second one.
I still want him te show me the data he found.
If i do this now he says that he haven't got enough info to fill op my dataAdaptor.
Wich is logic.
But i realy don't have a clue how to do this.. can you help me?
|
|
|
|
|
Start using if statements to check which parameters to use in your SELECT query.
something like:
StringBuilder sb = new StringBuilder();
sb.Append ("SELECT colom1, colum2, colom3, colom4, colom5 FROM Tabel1 ");
sb.Append ("WHERE ");
if (param2 != string.Empty)
sb.Append("(Colom1 = :param2)");
if (param3 != string.Empty)
sb.Append("(Colom2 = :param3)");
if (param4 != string.Empty)
sb.Append("(Colom3 = :param4)");
or if this is in a stored procedure, make IF statements in your stored procedure.
|
|
|
|
|
how t create server.exe.config file while creating simple chat application using remoting in c#.net
Karunas
|
|
|
|
|
Hi everyone,
can we load an external exe into a .net windows form.Say for example can we load adobe photoshop into a panel designated for it in a form.Please give your suggestions in this problem.Thanks in advance.
|
|
|
|
|
yes you can so far I know in ASP.net application quite not sure about windows form. In ASP.Net you can add reference to adobe from project reference tab and in .NET tab select adobe and add it to the project. This is way we can use external application in our .net application.
Share knowledge to enhance your learning
|
|
|
|
|
Hi Neel,
As far as i know we can add reference of only COM components or dlls.I wish, iam wrong.I have not tried with ASP.net.But are u quite sure about it.I dont mind the language .I am even ready to try java or any other language for this purpose.Please make me more clear...
Thanks
|
|
|
|
|
Hi all, having a little problem.
I started a new solution, where I've created 2 projects. I've set the solution to use single project startup and set the entry point within that project.
My second project only consists of classes, and therefore has no enty point.
The error I get is that there is no entry point for the second project.
I know it is just something small that I'm missing but just can't seem to figure it out.
Thanks in advance
|
|
|
|
|
Ensure that the output type of your second project is "Class Library". This setting can be found in the properties of the project.
www.troschuetz.de
|
|
|
|
|
Thanx a mil.
It was set to console output.
Knew it had to be something stupid.
|
|
|
|
|
Hi,
How To change a user's group or account type in c# (or command line)?
|
|
|
|
|
hi all,
I need to hide Windows console Application.
How Can I do it?
Main Method is Like this:-
[STAThread]
static void Main(string[] args)
{
CTService lobjFareReference=new CTService();
try
{
lobjFareReference.ExecuteProcess();
}
catch(Exception exception)
{
System.Diagnostics.Debug.Write(exception);
throw;
}
}
When I execute Main, A Black DOS Screen PopUp .Now I need to hide that screen..
How can I do it?
thanks in Advance..
|
|
|
|
|
Change your console app's Output Type (in the Application tab in Project Properties) to "Windows Application". Since you used the Console Application template when you created your project, it will still be a non-GUI app, but since you set the Output Type to Windows Application, no console window will be shown.
|
|
|
|
|
I'm currently working on a kind of custom FTP client. It's not really an FTP client from a user perspective, but from a backend perspective it most certainly is.
Specifically, what the program does is logs in to an FTP server, uploads one file, downloads another and then exits, giving the user the contents of the downloaded file (plain text).
I put something together in the space of only a few hours using System.Net.FtpWebRequest and testing was fine with my real FTP server. When it came to testing it in the real world however, I ran in to a couple of hiccups.
The FTP server my program connects to is VERY stripped down (as it's really only designed for this one specific task, not a general purpose FTP server) and doesn't accept the majority of standard FTP commands. A quick Ethereal trace of my program running showed that it connected okay, but died shortly after login - the FTP server isn't expecting what the client gives it at login (a couple of fairly standard commands) and instead of just ignoring it, it falls over and refuses to go any further.
SO - after all that explanation, my question is whether it's possible to and how I would go about stripping down the FTP client to ONLY send:
1) USER <username> (no password)
2) TYPE I
3) PORT <abc>
4) STOR <filename1>
5) PORT <xyz>
6) GET <filename2>
7) QUIT
Attempting to send anything else at all will cause this FTP server to fall over (no, I have no choice in the matter of the FTP server - it's in an embedded device).
(and if I can avoid having to do the PORT side of things manually, that'd be a plus too - but only out of laziness! I'll do it if I have to.)
If it's not possible to strip down the FTP client side of it, I could alternatively approach it from the other direction and do it without using System.Net.FtpWebRequest at all, in which case I'd REALLY appreciate some pointers or example code on writing an FTP client from the ground up in C#.
Any help would be greatly appreciated.
Regards,
Ben.
|
|
|
|
|
I have the following problem.
Say, that I have a class called Point which has x,y and the distance from (0,0).
There are two constructors, one take all three values and the other take only x ,y.
I subclass this to a circle class which has its own radius and distance from (0,0). To initialize I want to use two different constructor that use either of the base class constructors.
This causes an error in the program. Why is that, is there any solution
Check the following code and the error msg.
// Point3 class represents an x-y coordinate pair.
using System;
namespace CylinderTest
{
// Point3 class definition implicitly inherits from Object
public class Point3
{
// point coordinate
int x, y;
// default constructor
public Point3()
{
// implicit call to Object constructor occurs here
}
// constructor
public Point3( int xValue, int yValue )
{
// implicit call to Object constructor occurs here
X = xValue;
Y = yValue;
}
// property X
public int X
{
get
{
return x;
}
set
{
x = value; // no need for validation
}
} // end property X
// property Y
public int Y
{
get
{
return y;
}
set
{
y = value; // no need for validation
}
} // end property Y
// return string representation of Point3
public override string ToString()
{
return "[" + X + ", " + Y + "]";
}
} // end class Point3
}
// Circle4 class that inherits from class Point3.
using System;
namespace CylinderTest
{
// Circle4 class definition inherits from Point3
public class Circle4 : Point3
{
private double radius;
// default constructor
public Circle4()
{
// implicit call to Point constructor occurs here
}
// constructor
public Circle4( int xValue, int yValue, double radiusValue )
: base( xValue, yValue )
{
Radius = radiusValue;
}
// constructor
public Circle4( int xValue, int yValue )
: base( xValue, yValue )
{
}
// property Radius
public virtual double Radius
{
get
{
return radius;
}
set
{
if ( value >= 0 )
radius = value;
}
} // end property Radius
// calculate Circle diameter
public double Diameter()
{
return Radius * 2;
}
// calculate Circle circumference
public double Circumference()
{
return Math.PI * Diameter();
}
// calculate Circle area
public virtual double Area()
{
return Math.PI * Math.Pow( Radius, 2 );
}
// return string representation of Circle4
public override string ToString()
{
// use base reference to return Point string representation
return "Center= " + base.ToString() +
"; Radius = " + Radius;
}
} // end class Circle4
}
// Cylinder class inherits from class Circle4.
using System;
namespace CylinderTest
{
// Cylinder class definition inherits from Circle4
public class Cylinder : Circle4
{
private double height;
private double radius;
// default constructor
public Cylinder()
{
// implicit call to Circle4 constructor occurs here
}
// four-argument constructor
public Cylinder( int xValue, int yValue, double radiusValue,
double heightValue ) : base( xValue, yValue, radiusValue )
{
Height = heightValue; // set Cylinder height
}
// four-argument constructor
public Cylinder( int xValue, int yValue, double radiusValue,
double heightValue ) : base( xValue, yValue )
{
Height = heightValue; // set Cylinder height
Radius = radiusValue;
}
// property Height
public override double Radius
{
get
{
return height;
}
set
{
if ( value >= 0 ) // validate height
height = value;
}
} // end property Height
// property Height
public double Height
{
get
{
return height;
}
set
{
if ( value >= 0 ) // validate height
height = value;
}
} // end property Height
// override Circle4 method Area to calculate Cylinder area
public override double Area()
{
return 2 * base.Area() + base.Circumference() * Height;
}
// calculate Cylinder volume
public double Volume()
{
return base.Area() * Height;
}
// convert Cylinder to string
public override string ToString()
{
return base.ToString() + "; Height = " + Height;
}
} // end class Cylinder
}
lOOK FOR THE MULTIPLE CONSTRUCTORS IN CYLINDER AND CIRCLE THIS WILL NOT COMPLITE
ERROR
Class 'CylinderTest.Cylinder' already defines a member called 'Cylinder' with the same parameter types
A. Miftha Idroos
B.Sc. Engineering, AMBCS, AMIE(SL)
Hatton National Bank,
Sri Lanka
-- modified at 1:20 Monday 20th February, 2006
|
|
|
|
|
Standard question #2:
What error message do you get?
Standard question #3:
What does your code look like?
---
b { font-weight: normal; }
|
|
|
|
|
miftha wrote: // default constructor
public Cylinder()
{
// implicit call to Circle4 constructor occurs here
}
Oh no it doesnt!!
public Circle4():base()
<br />
{<br />
}
-- modified at 3:35 Monday 20th February, 2006
|
|
|
|
|
If you want two different constructors they have to have different parameters. What you have now is two constructors with the same parameters that do the same work, so I don't even see the reason for having both of them.
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
I'm binding an ArrayList of Structures to the DataGrid. The Arraylist is binded to the Datagrid but the column sequence changes (ie. the column sequence in the SP and the column sequence in the Datagrid differs). I'm using Datareader to fill the ArrayList and then bind it to the Grid. Can anyone tell me how to maintain the same column sequence in Datagrid as in the SP.
Regards,
Shah Adarsh.
|
|
|
|
|
I have to paint the menu background...
I alredy have a dll which sets the .net style for menu's.
This I want to do with toolbar. To paint just a background.
I want to do all this to match the GUI.
All other controls are in different colors. I want to paint this two controls (perhaps statusbar, but it's not very important) in more appropriate color to match the other controls.
Can I somehow paint the toolbar background, but to keep the buttons drawn by the OS?
I've asked Google, but no luck.
-- modified at 11:35 Monday 20th February, 2006
|
|
|
|
|
Hi,
I was wondering if Visual Studio 2003 supports reading XML file generated by saving Word Document 2003 as XML?
I was trying to read word doc xml into an empty dataset just like a regular xml file but DuplicationNameException error persists. The word XML is basically well-formed but the data view for the xml is unable to display the structures.
Could someone help explain to me the reason why? Im still working on Visual Studio 2003 and if this is a new feature of word document 2003 that is not supported in VS2003, then I have no choice but to acquire VS2005.
My goal is to be able to load a word document xml in a server (maybe sql server) and then be able to read back that xml, load into a dataset, display in a view keeping all the formatting properties of the contents of the word document.
If anyone has any idea to do this within the boundary of the Visual Studio and C#, I would really appreciate the help.
Thanks so much!
Teddy
|
|
|
|
|
Create a Microsoft Word document using MS Word editor. Apply your formatting, font & paragraph styles, page setup, etc. When you save your file, specify "Xml" as the file type. Now exit Word and open the WordML (XML) file in Notepad. See how and where the data is placed. You'll simply have to write an XSLT which takes in an XML (documnet) data and produces the output -- similar to what MS Word produced.
- Malhar
|
|
|
|
|
I've never used the datasets and tableadapters in visual studio before and I'm having some trouble trying to figure them out. Right now it's going like this. I have a strongly-typed dataset on my form, I also have a bindingsource that's bound to the dataset and my database table, this created a tableadpater for me. Now because some columns in the database are just id's that the user doesn't need to know about I don't have controls for them on my form. My question is how to I update this information in the dataset so that it's populated back to the database? I'm trying something like this, but I know it's not right.
Guid guid = Guid.NewGuid ();
myDataSet.myDataTable table = myTableAdapter.GetData ();
table.idColumn = guid.ToString ("N");
myBindingSource.EndEdit ();
myTableAdapter.Update (this.myDataSet.eps); I think the basic question is how to I update/insert/delete on a strongly-typed datatable from within code?
Thanks for any and all help
- Aaron
|
|
|
|
|
Hello, how can i make a C# function throw a certain exception? Thanks very much!
|
|
|
|
|
If you didn't write the function (i.e. if you can't change the source code), you cannot change what exceptions it throws, all you can do is throw whatever seems appropriate to you based on what the function returns.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
If you have written the function, to throw an exception you do this:
<br />
private void someFunction()<br />
{<br />
throw (new Exception());<br />
}<br />
But adjust the type of exception accordingly.
Is that what you wanted?
Hope that helps.
|
|
|
|