Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 SQL server date field value from SQL to VFP6

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-03-04 : 22:22:58
Gretchen writes "I am trying to pass a date from a table in SQL server to update a table in VFP6. I have tried to use a datetime data type, varchar, etc., and when I run the stored procedure in the query analyzer all I get is the message (0 row(s) affected). The field in foxpro is a datetime field, and sometimes I get the message "cannot convert varchar to datetime."

When I print my sql statement it looks like this:

Update openquery([TST_M2M],'Select * from jodrtg WHERE fjobno = "12150"') set flastlab = '11/14/2001 1:30:59 PM'



My stored procedure looks like this:

CREATE PROCEDURE [dbo].[spM2MUpdateJodrtgDate] 
@Jobno char(10), @M2MfLastLab varchar(25)

AS

Declare @SQLString varchar(8000)
Declare @SQLString2 varchar(8000)
Declare @DQ varchar (1)
Declare @SQ varchar(1)

SET @DQ = CHAR(34)
-- Double Quotes

SET @SQ = CHAR(39)
-- Single Quotes

-- always use select * - do not use field names
--this will be called PRD_DATA instead of TST_M2M when this sp is put into production. (name of dsn on server)

Set @SQLString = 'Update openquery([TST_M2M],'
+@SQ + 'Select * from jodrtg WHERE fjobno = ' +@DQ+rtrim(@Jobno) +@DQ + @SQ +')'


set @SQLString2 = ' set flastlab = '
+@SQ + @m2mflastlab + @SQ

--+@DQ+ rtrim(@M2MFlastLab) +@DQ
--above line is previous code

set @SQLString = @SQLString + @SQLString2

exec (@SQLString )

Declare @Error as int
Declare @Rowcount as int

Select @Error = @@Error, @Rowcount = @@Rowcount

IF @Error = 0
Begin
IF @Rowcount = 0
Begin
Set @Error = 99 --No records updated/inserted
End
End
Return(@Error)
GO"

philh
Starting Member

18 Posts

Posted - 2002-06-18 : 12:21:19
(Gee this is old but whatever)

The error doesn't lie, Gretchen. You need to pass a format that VFP understands to be a date:

{^'YYYY-MM-DD'} usually works.

HTH

quote:

Gretchen writes "I am trying to pass a date from a table in SQL server to update a table in VFP6. I have tried to use a datetime data type, varchar, etc., and when I run the stored procedure in the query analyzer all I get is the message (0 row(s) affected). The field in foxpro is a datetime field, and sometimes I get the message "cannot convert varchar to datetime."

When I print my sql statement it looks like this:

Update openquery([TST_M2M],'Select * from jodrtg WHERE fjobno = "12150"') set flastlab = '11/14/2001 1:30:59 PM'



My stored procedure looks like this:

CREATE PROCEDURE [dbo].[spM2MUpdateJodrtgDate] 
@Jobno char(10), @M2MfLastLab varchar(25)

AS

Declare @SQLString varchar(8000)
Declare @SQLString2 varchar(8000)
Declare @DQ varchar (1)
Declare @SQ varchar(1)

SET @DQ = CHAR(34)
-- Double Quotes

SET @SQ = CHAR(39)
-- Single Quotes

-- always use select * - do not use field names
--this will be called PRD_DATA instead of TST_M2M when this sp is put into production. (name of dsn on server)

Set @SQLString = 'Update openquery([TST_M2M],'
+@SQ + 'Select * from jodrtg WHERE fjobno = ' +@DQ+rtrim(@Jobno) +@DQ + @SQ +')'


set @SQLString2 = ' set flastlab = '
+@SQ + @m2mflastlab + @SQ

--+@DQ+ rtrim(@M2MFlastLab) +@DQ
--above line is previous code

set @SQLString = @SQLString + @SQLString2

exec (@SQLString )

Declare @Error as int
Declare @Rowcount as int

Select @Error = @@Error, @Rowcount = @@Rowcount

IF @Error = 0
Begin
IF @Rowcount = 0
Begin
Set @Error = 99 --No records updated/inserted
End
End
Return(@Error)
GO"




Phil Hegedusich
Senior Web Developer
IIMAK
http://www.iimak.com
The best thermal transfer printer ribbons on the planet
Go to Top of Page

Sitka
Aged Yak Warrior

571 Posts

Posted - 2002-10-24 : 16:07:25
wow, {^'YYYY-MM-DD'} brings back memories of some great battle.
Maybe next year someone will go back in time, step a on a bug change the course of history and wipe FoxPro from it's place within it. You ain't never seen such iteration! I'm dealing with it's weak disintegrated corpse on a daily basis, common old man..die already.

But I think that date format is derived from X-Base but I'm no historian...but yeah that was a battle those curly baces, this thing ^ and ODBC,.. who knew...who cared...sad really,?? Should have bailed before I figured it out.


Voted best SQL forum nickname...."Tutorial-D"
Go to Top of Page
   

- Advertisement -