Solved

Embedded two SQL statement in ADODC.Recordset.Open

Posted on 2000-04-13
13
223 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
 

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now