Solved

Embedded two SQL statement in ADODC.Recordset.Open

Posted on 2000-04-13
13
225 Views
Last Modified: 2008-03-17
I need to set the date format to based on the system locale and once I have captured the date, I will update it to a SQL Server Database with an unknown date format.

Hence I am thinking of doing the following:

commandvar="set dateformat ymd" + Chr(10) + "sp_updatesometable blar blar blar"
recordset.open commandvar, connectionobject

However, when I tried that, it gives error.

Please help!  Thanks you in advance.

Note:
The command work in query analysier
The recordset.open works when the commandvar contain only one SQL statement
0
Comment
Question by:kahhoe
  • 5
  • 3
  • 2
  • +3
13 Comments
 
LVL 1

Expert Comment

by:ATM
ID: 2714638
Have You try :
Convert (datetime,@strval,dformat)

I prefer to use that one when deal with datetime.

for example:
@strval='14/04/2000' passed as varchar(10) to procedure and converted with 103 code.
0
 
LVL 1

Expert Comment

by:ATM
ID: 2714714
replace chr(10) with vbCrLf, do it work?
0
 
LVL 1

Expert Comment

by:sunj
ID: 2714764
listening...
0
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 

Author Comment

by:kahhoe
ID: 2714845
not sure if this is valid.

I have tried running the two statement separately and it seems that that behaviour is as expect.  The date format is changed and the second statement can go through smoothly.
0
 

Expert Comment

by:Olli083097
ID: 2714935
Isn't the date format equal on all SQL systems? (MM/DD/YYYY)
0
 

Author Comment

by:kahhoe
ID: 2714940
if you are using SQL Server, you can set the dateformat at syslanguage at master table.  Depending on the langid you are using, you can use different date format.

Actually the dateformat in the SQL Server should be dmy or ymd or blar blar blar. I don't remember seeing MM/DD/YYYY.
0
 
LVL 2

Expert Comment

by:BobbyOwens
ID: 2714971
Have you tried sometrhing like the following?

dim strSQL as string

strSQL="set dateformat ymd " & vbcrlf
strSQL=strSQL & "go " & vbcrlf
strSQL=strSQL & "sp_updatesometable blar blar blar "
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 2714999
I always pass datetime variables using the following string format (if i don't use Parameters collection of the ADODB.command object)
yyyy/mm/dd
0
 

Author Comment

by:kahhoe
ID: 2715101
I have tried.  Observation.

1. Go statement wouldn't work
2. If the statement contain stored procedure, it wouldn't work also
3. It only work if everything is purely SQL statement but it is not necessary to cascade those statement together because you can execute the two statement together.
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 2715104
For the stored procedure, you need to add EXEC before it, and it WILL work
0
 

Author Comment

by:kahhoe
ID: 2715178
Thanks you!  It really works.

btw, Who should give my marks to?
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 50 total points
ID: 2715185
Your decision
You may ask the EE Support to split points...
0
 

Author Comment

by:kahhoe
ID: 2715204
I think you solved my question directly.

Many Thanks AngelIII!
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question