|
|
HI,
i am trying to retreive records for order with in a specified range of dates. I have created sql string as follows :
//create the sql
sql = "SELECT * FROM vShipments WHERE DateOrdered BETWEEN'" + txtOrderDateFrom.Text + ", '" + "AND '" + txtOrderDateTo.Text + "'";
-------------------------------------------
On execution, i am getting following error(s) :
System.Data.SqlClient.SqlException: The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
at System.Data.SqlClient.SqlDataReader.Read()
at InventoryControl.frmShipments.PopulateListView(String filter) in d:\shirtuniverse\inventorycontrol\frmshipments.cs:line 786
------------------------------------------------------------
Any idea(s) : what i am doing wrong
Thanx in advance
|
|
|
|
|
ronin1770 wrote:
//create the sql
sql = "SELECT * FROM vShipments WHERE DateOrdered BETWEEN'" + txtOrderDateFrom.Text + ", '" + "AND '" + txtOrderDateTo.Text + "'";
Looking this over are you sure you need the comma after the first date. Its inside the single quote. You might try:
sql = "SELECT * FROM vShipments WHERE DateOrdered BETWEEN '" + txtOrderDateFrom.Text + "' AND '" + txtOrderDateTo.Text + "'";
Steve Maier, MCSD MCAD
|
|
|
|
|
ronin1770 wrote:
Any idea(s) : what i am doing wrong
This probably isn't what you were looking for, but I feel that I'd be remiss if I didn't point it out anyway.
Since you're simply echoing user input (txtOrderDateTo.Text ) into a SQL statement, you have left yourself wide open to a SQL injection attack. Google will yield you a good set of results on a search. For convenience, here is an article[^] to get you started.
Hope that helps a bit.
--Jesse
|
|
|
|
|
ronin1770 wrote:
Any idea(s) : what i am doing wrong
So many things, it's almost funny!
1) You're using string concatentation to build an SQL statement. The gods around here will smite you for such foolishness. Like the other posters pointed out, you have opened yourself up to many an SQL injection attack.
2) There is no space between the keyword BETWEEN and the single quote next to it. There should be...
3) A comma between your first date and the keyword AND will cause an error in the SQL statement.
4) Your completely at the mercy of the user to type in the date in the EXACT format that is required by the SQL statement.
We've said this a thousand times in the forums: CONVERT THIS STATEMET INTO A PARAMETERIZED QUERY! If you were to release code like this into a production application and sell it, your customers will hang you by your nads when they find out about it!
The SqlParameter objects will handle filtering for SQL Injection attacks for you and handle converting the DateTime objects you supply into the correct SQL format.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi everyone:
I am at present trying to configure a web service but I am having some trouble right from the get go.
When I follow the example, I get an error message telling me "The Web server reported the following error when attempting to create or open the Web project located at the following URL: 'http://thisComputer/WebService1'. 'HTTP/1.1.400 Bad Request'.
I recognize that I have my file servert set up wrong, and that's quite the issue. I can't seem to get just a normal document server up and running as it used to. I think it has to do with a conflict being caused by a SharePoint server I am running. I know that SharePoint filters out your sites so that it can check if they are extended or not.
When I set up a file server using the administration tools and just put a simple index.htm in the folder (or any other default welcome page) I indeed cannot access it.
Can anyone offer any suggestions for my plight?
Thanks a lot!
Jim
|
|
|
|
|
Okay, we got that one working, but now we have been presented with new and fabulous problems. I am trying to reference a com object (which i HAVE referenced).
My code compiles fine.
When i try to instantiate a class from the reference though everything falls to pieces. E.g.
oPPT = new PowerPoint.ApplicationClass();
When I do that it seems to fail. I put the [STAThread] on the method, but that still doesn't work.
Can anyone help me?
Thanks a LOT!
|
|
|
|
|
Just want to have a clear understanding of the following (related) issues:
1. Private/Shared Assembly allows us to have some sort of "binary reuse": for instance, you can create a assembly (either private or shared) which contains some "utility" types, then in another application, you can add a reference to the above assembly and make use of the types in it. Yet you can create another different application still use this same assembly ... we may call these different applications clients, and the utility assembly server.
2. .NET remoting: this architecture allows us to invoke a method on a remote object, again, the remote object can be considered as server, the application who invokes the methods can be view as client.
3. classic COM/DCOM: you can build COM server which has the coclasses, you can also have a client that consume the functions of those coclasses. at run time, the COM runtime (quite like the CLR) will load the COM server so the COM client can have someone to talk to.
So, what exactly is the difference among these three??? for example, the private/shared assembly as a server, it in fact lives in the same AppDomain with its client, but in the .NET remoting model, the client and server are for sure not in the same AppDomain, so this model is about crossing the AppDomain boundaries.
can someone summarize more differences?
|
|
|
|
|
For the .NET Remoting, you can also call into a different machine like with DCOM, but it could also be to the same box too. With .NET Remoting you can specify if you want the communication to use TCP or HTTP, and either binary or SOAP encoding. SOAP encoding is text based so it can slow things down, but can be easier to trace at times.
Steve Maier, MCSD MCAD
|
|
|
|
|
thanks steve, good point. basically, the .NET remoting allows you to customize the whole underlying architecture if you so choose.
by the way, I also notice that you have the MCSD and MCAD certs. congratulations!! would you mind telling me which 3 exams you took for the MCAD cert?
thanks!
|
|
|
|
|
I have taken :
70-320 XML Web Services with C#
70-315 Web Applications with C#
70-300 Analyzing Requirements and Defining Microsoft .NET Solution Arch.
70-316 Windows®-based Applications with C#
Just an elective to go to finish my MCSD.NET.
Steve Maier, MCSD MCAD
|
|
|
|
|
Hi guys,
I have been working on an application in C# and have finally got to the fun stage of creating the help files.
I found the VS Help Integration Toolkit and have installed this and created a simple help 2.0 file with a few html files. The problem is that I now cannot work out how to launch this HxS file in my application.
Any ideas?
Cheers
Mike
|
|
|
|
|
Hey I would like to control the creation of a dataset instance, when i drag and drop it into the designer.
The current designer add a new instance... like so:
this.dataSet1 = new System.Data.DataSet();
in the "Designer generated code" #region.
How do I change this into something I define... FX:
this.dataSet1 = DataSetSingleton.Instance.MyDataSet;
???
I think I need to make a new type converter but im not sure...
|
|
|
|
|
Hello,
I want to add a new row to my dataset, so I use the AddNew() method.
The problem I have is that in my database definition I have defined a default value for some of the fields.
How can I get this default values in my new row?
Thanks
|
|
|
|
|
Hi.
The DataColumn class exposes a DefaultValue property that you should be able to use.
Example:
DataTable table = new DataTable("SomeTable");<br />
table.Columns.Add("Column1", typeof(string));<br />
table.Columns.Add("Column2", typeof(string));<br />
<br />
table.Columns["Column1"].DefaultValue = "Foo";<br />
table.Columns["Column2"].DefaultValue = "BlahBlah";
If you were to execute the code above, then add a row to the table it creates, the row's Column1 value would be preset to "Foo" and the Column2 value would be "Blah".
Hope this helps,
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
This is indeed a solution, but I wanted to avoid putting these default values into my program. That's why I've filled in these values while creating my SQL table.
So I was hoping for a trick to get/read these values into the program.
Can I retrieve default values from a database using Stored Procedures?
Thanks
|
|
|
|
|
The example I provided was simply to indicate that default values were available at design-time for the System.Data.DataColumn class.
If you want to determine the characteristics of columns in your database at runtime, there are a number of ways to do it. You could use SQL to inspect the system tables in your database directly or you could use something like System.Data.OleDb.OleDbConnection.GetOleDbSchemaTable to retrieve tons of information about your physical database.
For instance, to retrieve column info, you might use (where conn is an OleDbConnection):
DataTable columnInfo = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, new object[4]{null, null, "MyTable", null});
The call uses the OleDbSchemaGuid class to specify the type of database object you're trying to fetch information about, and the object array is a list of restriction values (like a filter) that determines which specific instance(s) of the database object type you want to investigate.
Best of luck.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
Hi,
I need to have UI more or less same as VS .NET editor.
It should have panes as "Solution explorer", and "Output Window".
The toolbars and the menus should be the same as .NET editor.
If anyone has any sample code, will be very helpfull.
Thanx in advance
Saleem.
|
|
|
|
|
Tremble in awe at the power of the almighty Google! SharpDevelop[^], an open source .NET IDE.
In all seriousness, this really isn't the place for this kind of post. The CodeProject community is happy to help with a specific issue that you're having while working on your application, but please don't post asking someone to find you code that matches your requirements. If you are just looking to "borrow" from others, please, at least, do your own searching of Google, the articles, and message boards. If none of those help, you may wish to try Rent-A-Coder[^].
--Jesse
|
|
|
|
|
You might want to take a look at DotNetMagic[^]
"I think I speak on behalf of everyone here when I say huh?" - Buffy
|
|
|
|
|
I have a radio button.On click of that radio button ,the text box present should be enabled.
I found that no click event is available for the radio button.
pls help
Sukanya
|
|
|
|
|
You should use the CheckedChanged property.
ex:
RadioButton1_CheckedChanged(object sender, System.EventArgs e)
{
if (RadioButton1.Checked == true)
{
TextBox1.Enabled = true;
}
}
Paul Lyons, CCPL Certified Code Project Lurker
|
|
|
|
|
This did not work
pls suggest something
there is no click event for the server side control
what to do?
Sukanya
|
|
|
|
|
Ah ha... You didn't say you were using it on a WebForm.
Have a look at this[^].
Note that the control does not immediately cause the page to post back to the server by default. You need to set the AutoPostBack property to true for an immediate reaction to it's change in state.
Hope this helps you.
Paul Lyons, CCPL Certified Code Project Lurker
|
|
|
|
|
You could use the mouse down event - you can use the MouseEventArgs parameter to test which mouse button was used.
|
|
|
|