Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Embedded two SQL statement in ADODC.Recordset.Open

Posted on 2000-04-13
13
Medium Priority
?
232 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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 143

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 143

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 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 200 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

886 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