Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default excel dates in sql procedures

I am still getting sql syntax error.

Here is my procedu

Sub ABC()
Dim qt As QueryTable
Dim a As String
Dim b As String

Sheets("abc").Select
a = Range("a1").Text
b = Range("a2").Text

sqlstring = "exec emputilization " & a & "," & b

"ODBC;DSN=empdata;UID=;PWD=;Database=empdata"

Sheets("Temp").Select
With ActiveSheet.QueryTables.Add( _
Connection:=connstring, _
Destination:=Range("A1"), Sql:=sqlstring)

..Refresh

End With


End Sub


Sheet "abc" : A1 is the startdate 1/1/2007 and A2 is the enddate 1/31/2007


Any help is appreciated.

Thanks,

ragup


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default excel dates in sql procedures

Just a suggsetion. Try

sqlstring = "exec emputilization " & _
Format(Range("A1").Value, "\#dd mmmm yyyy\#") & "," & _
Format(Range("B1").Value, "\#dd mmmm yyyy\#")

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"ragup001" wrote in message
...
I am still getting sql syntax error.

Here is my procedu

Sub ABC()
Dim qt As QueryTable
Dim a As String
Dim b As String

Sheets("abc").Select
a = Range("a1").Text
b = Range("a2").Text

sqlstring = "exec emputilization " & a & "," & b

"ODBC;DSN=empdata;UID=;PWD=;Database=empdata"

Sheets("Temp").Select
With ActiveSheet.QueryTables.Add( _
Connection:=connstring, _
Destination:=Range("A1"), Sql:=sqlstring)

.Refresh

End With


End Sub


Sheet "abc" : A1 is the startdate 1/1/2007 and A2 is the enddate
1/31/2007


Any help is appreciated.

Thanks,

ragup




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default excel dates in sql procedures

sqlstring = "exec emputilization '" & a & "','" & b & "'"



--
Tim Zych
SF, CA

"ragup001" wrote in message
...
I am still getting sql syntax error.

Here is my procedu

Sub ABC()
Dim qt As QueryTable
Dim a As String
Dim b As String

Sheets("abc").Select
a = Range("a1").Text
b = Range("a2").Text

sqlstring = "exec emputilization " & a & "," & b

"ODBC;DSN=empdata;UID=;PWD=;Database=empdata"

Sheets("Temp").Select
With ActiveSheet.QueryTables.Add( _
Connection:=connstring, _
Destination:=Range("A1"), Sql:=sqlstring)

.Refresh

End With


End Sub


Sheet "abc" : A1 is the startdate 1/1/2007 and A2 is the enddate
1/31/2007


Any help is appreciated.

Thanks,

ragup




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I import SQL Stored Procedures into Excel? Nick Gill Excel Discussion (Misc queries) 0 September 11th 08 11:42 AM
Excel VBA procedures running at erratic speeds Gesualdo Excel Programming 12 February 25th 08 10:22 AM
Running sql stored procedures from Excel in-over-his-head-bill Excel Discussion (Misc queries) 0 July 5th 06 06:30 PM
Can Access stored procedures be executed from within Excel rmcompute Excel Programming 0 November 19th 05 10:14 PM
Using Excel to handle Com callback procedures Aaron Graham Excel Programming 5 February 5th 04 04:00 PM


All times are GMT +1. The time now is 06:25 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"