Just create a function that replaces all your ' (single apostrophe) with '' (TWO single apostrophe),
i.e. [Joe O'Connell] becomes [Joe O''Connell]
However, I do recommend using Data Adapters and SQLCommands to pass your parameters so you don't need to worry about this anymore.
It does make my life easier aside from being safer from SQL injection.
After doing try catch within the error block I caught such exception:
System.Data.SqlClient.SqlException: @dtExpireDate is not a parameter for procedure pr_EditTreatInstrument. at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at.... so on
and when I excluded @dtExpireDate, then I see exception like
System.Data.SqlClient.SqlException: Procedure 'pr_EditTreatInstrument' excepts parameter '@dtExpireDate', which was not supplied. at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) at... so on
Thank you, Sudee
You need a head to program. Cool, fast and sharp.
I have just noticed a problem in my db with the date format. The problem is that some servers are set to interpret dates differently, eg mm/dd/yy or dd/mm/yy. My problem is to find out which it needs and which to supply. I have also been told that the format of dates is an int, and just adds to 1/1/1900 to get the desired result. I am not sure how this works, but it sounds like it could fix my problem.
If you know of a way that I can parse a date to the db, and it will then decide how to format it, or whatever solution you have in mind, please let me know.
The most reliable and cross-platform compatible way of handling dates that i have found it to use the format "YYYY-MM-DD", optionally "YYYY-MM-DD HH:MM:SS". It's unambiguous, and every DBMS i've used handles it fine.
If you're using MS SQL Server though, you can use any format you like, and remove ambiguity before your query using "set dateformat". see books online for that.
I'm with Jon. Either use an ODBC Canonical date (YYYY-MM-DD HH:mm:SS.ffff) or use an ISO standard date (YYYYMMDD HH:mm:SS.ffff) Any DB server, regardless of regional settings, should correctly handle either of these formats.
Thanks. But I dont think it's in the article though. I haven't gone thru it all yet. But read up to the section on ALGORITHM class implementation (stub code) and the include files mentioned are nowhere to be found.
DmhMemory.h and DmhMemory.cpp
DmhLocalization.h and DmhLocalization.cpp
ParamHandler.h, and ParamHandler.cpp
dmalgo.h and oledbdm.h
And they're not in article or Analysis Services installation directory.
I have an access database, and I have a small program that is using an OLEDBDataAdapater to retrieve the information. The problem is that it pulls multiple items (which it must be able to do.) I need to be able to bind the results to a textbox or some control that allows for multiple selection with copy ability. Any help would be greatly appriciated. TIA
Thanks for your suggestion,
unfortunately that won't work in my case.
I'm distributing the application on CD and want it to install a complete SQLServer database on the target machine along with the application itself.
So no way will the target machine have access to the SQLServer on my development machine.
Last Visit: 31-Dec-99 18:00 Last Update: 1-Oct-23 1:40