Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Embedded two SQL statement in ADODC.Recordset.Open

Posted on 2000-04-13
13
226 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

839 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