|
Is there anyway to have the date format set permanently for a database? I think SET DATEFORMAT only sets it for the current session. If there's no way to set it permanently does anyone know how to execute a SET DATEFORMAT using ADO? I'm using the following ADO Wrapper Class[^]. I've tried the Execute function of the database object, but it isn't working. Any ideas would be appreciated. Thanks.
- Aaron
|
|
|
|
|
The default value depends on the client program's locale, IIRC.
This option only applies to how date literals are interpreted by the parser; to ensure that date literals are interpreted correctly, whatever locale is in use, you should supply them in ISO format:
yyyymmdd, e.g. today is '20040413' .
For dates supplied by a user, use the parameter features of ADO (i.e. use CADOCommand::AddParameter with the type CADORecordset::typeDate and use COleDateTime or similar to prepare the value).
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
First, thanks for the reply Mike. Second, I'm now taking your advice and I'm trying to enter an ISO format date, but everytime I try to set the field value I'm getting a _com_error thrown. The error is being thrown by the put_Value function in the msado15.tli file:
inline void Field20::PutValue ( const _variant_t & pvar ) {
HRESULT _hr = put_Value(pvar); <-- Error returned from put_Value
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); <-- exeception thrown here
} The debugger is telling me that it's an "IDispatch error #3105", but I can't find any information on this error anywhere. The _com_error has a filed called __vfptr, which seems to have a value of 0x00469707 _com_error::`scalar deleting destructor'(unsigned int), but I don't know if that's related or not. Some of the values I'm passing in are "2003123182300", "20040104124857" these are date and time values. These are the only values I'm getting an exception on and I can't figure out what's wrong. I'm using ADO classes here[^]. Any help is very appreciated as I'm completely dumbfounded by this. If you'd like the code I'm using just let me know. Thanks!
[UPDATE]
Well I just tried manually adding a value like "2003123182300" to the database and received a "Syntax error converting datetime from character string." error. So I guess that's probably why I'm getting the exception, but if I can't add a value like that how do I add an ISO date/time value to the database?
[/UPDATE]
- Aaron
|
|
|
|
|
Is is possible to setup the format of a column so that in a select it has a certain format? For example in Oracle I could do something like:
column columnname format a18
column columnname truncated This would format columnname so that it was only 18 characters wide and would trucate any extra characters. Is there anything like this for SQL Server (I'm using MSDE). Thanks.
- Aaron
|
|
|
|
|
select cast(test_column as char(15)) from test_table
This will truncate the column to 15 characters if it exceeds it, or pad on the right if the column doesn't
select cast(test_column as char(15)) from test_table
test_column
---------------
1234567890
12345
(2 row(s) affected)
select cast(test_column as char(5)) from test_table
test_column
-----------
12345
12345
(2 row(s) affected)
The test_table had two rows, test_column was "1234567890" on the first row and "12345" on the second.
There is also a convert function you may like to look up which gives finer control of the output format (especially for dates) if you need it.
Does this help?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
|
|
|
|
|
That helps quite a bit. Thanks very much for the information. The only thing is that with that format you have to do it in every select statement. Is there anyway to make it more global (at least for a session) so that whenever a specific column is involved it gets the format that you give it? If not I can definately use the cast function. Thanks again for the help.
- Aaron
|
|
|
|
|
I've written a fairly simple C# application that reads an MSDE database. The project is to distribute this application and database on CD.
The client would install the application and the database would reamain on cd.
My application works fine, the problem is developing a solid set up routine for deploying the application and MSDE.
A toolkit and a dozen articles exist on the MS site but not one executable example.
Does anyone have a small example of a 'setup' application to install an application, MSDE and it's database.
Thank you,
cb
|
|
|
|
|
|
I've tried to install the add-in and get a 'failed to load ... unknown error 80131500.
I uninstalled Studio.NET and tried it again and still got the same error.
What next.
cb
|
|
|
|
|
What version of Visual Studio .NET u use?? 2002 or 2003???
There is nothing new under the sun, But there are lots of old things we don't know. - Ambrose Bierce
|
|
|
|
|
|
OK, in the 2003 VS.NET...
When did the error message apprear?? During the installation of the plugin??
I had no issues in my case. If you have any installation problems for the plugin, you try to re-install the same after rebooting the PC
There is nothing new under the sun, But there are lots of old things we don't know. - Ambrose Bierce
|
|
|
|
|
I get the error when I start a new 'startup project' and then select the add-in through the add-in manager.
I've reinstalled everything with the same results.
cb
|
|
|
|
|
Did u follow the instructions as in the document?? Please write down the steps u followed
There is nothing new under the sun, But there are lots of old things we don't know. - Ambrose Bierce
|
|
|
|
|
I ran the setup for the toolkit
I put a copy of the dotnetfx.exe in the C:\Program Files\Microsoft\MSDE 2000 Deployment Toolkit\Template\CD directory.
I started a new setup project.
I selected Tools^Add-in Manager then checked the MSDE 2000 Bootstrap Loader Configurator.
That's when I get a dialog that indicates that the add-in failed to load with and unknown error 80131500 and offers to remove the add-in.
cb
|
|
|
|
|
hmm I have no idea about the error message sorry
There is nothing new under the sun, But there are lots of old things we don't know. - Ambrose Bierce
|
|
|
|
|
I contacted the reference in the documentation and found out that although the dates on the package was the same as the one I downloaded ... One of the .dlls (M2KBSLC.dll)had changed.
I redownloaded the toolkit (for about the 5th time) and did a reinstall.
In the end it worked.
Thanks for your help!
|
|
|
|
|
betterc wrote:
In the end it worked
There is nothing new under the sun, But there are lots of old things we don't know. - Ambrose Bierce
|
|
|
|
|
Can I use ADOX and ADO libraries in the same program?
Shenthil
|
|
|
|
|
|
My problem has 2 workflows:
WF1:=>I'm OK<=With an active connection, the user can drag and drop fields in a table and I'm succesfully generate an SQL string.
WF2:=>I'm now in trouble<= I let the user type the SQL string in a richtextbox. And now I must display all the tables, the relation ships, the fields etc... specified in the SQL string typed by the user. Would you please give me some helps? I really need an effective algorithm to parse this SQL string. Thank you in advance
|
|
|
|
|
I have written a basic SQL parser before, but it was parsing generated SQL, which was fairly tightly under my control anyway. I would not want to do it for SQL that the user typed! SQL can be very complex, with nested queries and multiple ways of writing the same query. Most typed queries will be simple though, so maybe you can get by with something basic, that works in 90% of cases.
Alternate solution 1: I would leverage what I could from SQL Server. In SQL Query Analyzer, you can look at the query plan for a particular query. This shows some of what you are interested in. Perhaps you could find out how that is done, and use a similar technique.
Alternate solution 2: SQL Enterprise and SQL Query analyzer both have a query designer tool that does something similar to what you want. It may be that there is an underlying API that you could utilize.
Alternate solution 3: Create a temporary view from the SQL, and then use various techniques to analyze that view. sp_depends will tell you the tables, sp_help will tell you the result structure. Not sure how you would tell the relationships though.
|
|
|
|
|
Would you please tell me more about the Solution 2? It will be better if I can utilize some API, but which API? Can you show me an example using these API? And would you mind send me your project that you've written? Thank you.
|
|
|
|
|
Hi
We are facing an acute situation in our web-application. Technology is ASP.NEt/VB.NET, SQL Server 2000.
Consider a scenario in which User 1 is clicking on a button which calls a SQL stored procedure. This procedure selects Group A of records of Database Page1.
At the same time if User 2 also clicks the same button which calls same SQL stored procedure. This procedure selects Group B of records of Database Page1.
So, its the same Page1 but different sets of records. At this moment, both the calls have shared locked on the Page1 inside the procedure.
Now, in call 1, inside the procedure after selecting Group A of records, the next statement is and update to those records. As soon as update statement executes, SQL Server throws a deadlock exception as follows :
Transaction (Process ID 78) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction
We are able to understand why its happening. Its because, Group A and Group B of records are on the same Page1. But both the users have shared lock on the Page1. So, no one gets the exclusive lock in records for update, even though, the records are different.
How can I resolve this issue? How can I get lock on wanted rows instead of entire page?
Please advice. Thanks a bunch.
Pankaj
Follow your goals, Means will follow you ---Gandhi---
|
|
|
|
|
You can use WITH ( ROWLOCK ) after the table name in the FROM clause. However, you should consider whether you should be holding your transactions open for user interaction. It's usually better to select the results and release the locks, then perform comparisons to determine if the row has changed when the user wants to update. It's up to you what you do if another user has changed a row since this user started editing.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|