SQL Server datetime error

Alex Y. wrote:

NoobSaibot wrote:

@project is in the list of instance_variables

What if you type ‘@project’? Sorry if this is going over old ground,
but if I remember correctly (and I’ll be glad to be proved wrong here),
the puts method dumps the data out to the original console the server’s
running on, not the breakpointer. The return value of puts is nil.

you’re absolutely write. what i had to do is

…> [@project]

which would print out the object (and its attributes)

Allright, thanks Alex. Still i’m unable to format the dates.

i wonder if i’m the only one with this kind of problems?

Noob,

Could you run the following on a fresh schema (using SQL Query
Analyser or similar), and tell me which insert statements work and
which do not? If they all work, could you provide me with the schema
that’s causing you problems.

Tom

CREATE TABLE (
id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
[date] datetime default NULL,
);

INSERT INTO date_test ([date]) VALUES (‘2006-05-04 03:21:00’)
INSERT INTO date_test ([date]) VALUES (‘20060504 03:21:00’)
INSERT INTO date_test ([date]) VALUES (‘2006-05-04T03:21:00’)

INSERT INTO date_test ([date]) VALUES (convert(datetime,‘2006-05-04
03:21:00’))
INSERT INTO date_test ([date]) VALUES (convert(datetime,‘20060504
03:21:00’))
INSERT INTO date_test ([date]) VALUES
(convert(datetime,‘2006-05-04T03:21:00’))

NoobSaibot wrote:

Here’s the schema – as all of your stuff worked:

CREATE TABLE [dbo].[projects] (
[id] uniqueidentifier ROWGUIDCOL NOT NULL ,
[created_at] NULL ,
[title] [varchar] (500) COLLATE Latin1_General_CI_AS NOT NULL ,
[description] [text] COLLATE Latin1_General_CI_AS NULL ,
[starts_at] NULL ,
[ends_at] NULL ,
[updated_at] NULL
)

The funny thing is that the same sql insert statement – which is
claimed to be wrong by ror – does work if i put it in the query
analyzer.

maybe it’s the encoding or something?

Here’s the schema – as all of your stuff worked:

CREATE TABLE [dbo].[projects] (
[id] uniqueidentifier ROWGUIDCOL NOT NULL ,
[created_at] NULL ,
[title] [varchar] (500) COLLATE Latin1_General_CI_AS NOT NULL ,
[description] [text] COLLATE Latin1_General_CI_AS NULL ,
[starts_at] NULL ,
[ends_at] NULL ,
[updated_at] NULL
)

Tom W. wrote:

Can I ask how you connect to SQL Server (through ODBC or ADO)

i’m using ADO to connect to db

which version of SQL Server you connect to.

2000 sp3

And here’s the encoding i’m using for my html files (if that matters)

The funny thing is that the same sql insert statement – which is
claimed to be wrong by ror – does work if i put it in the query
analyzer.

maybe it’s the encoding or something?

I guess that’s a possibility. There’s nothing in the schema that
seems strange, the failing SQL works fine on both our systems through
query analyser.

Can I ask how you connect to SQL Server (through ODBC or ADO) and
which version of SQL Server you connect to.

Tom

unfortunately i get the same error message

On 1/25/06, NoobSaibot [email protected] wrote:

Tom W. wrote:

Can I ask how you connect to SQL Server (through ODBC or ADO)

i’m using ADO to connect to db

Can you try connecting through ODBC instead. Either using a dsn
configured via control panel, or with a connection string. Examples
below (obviously change values to match your configuration):

development:
adapter: sqlserver
mode: ODBC
dsn: Driver={SQL Server};Server=(local);Database=rails;Uid=sa;Pwd=
username: sa
password:

development:
adapter: sqlserver
mode: ODBC
dsn: my_datasource_name
username: sa
password:

On 1/25/06, NoobSaibot [email protected] wrote:

unfortunately i get the same error message

Running out of ideas here, unfortunately. When you added a breakpoint
and inspected the project object, what output did you get?

Tom

On 1/25/06, NoobSaibot [email protected] wrote:

Here’s the output for [@project]
}>
]


Posted via http://www.ruby-forum.com/.


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

Funny, I thought we just covered this?
There is a bug in teh German-Language pack of SQL Server that boggles up
datetime conversion to/from string.

I googled it but couldn’t find my reference back.

Funny, I thought we just covered this?
There is a bug in teh German-Language pack of SQL Server that boggles up
datetime conversion to/from string.

I googled it but couldn’t find my reference back.

i’m sorry if i missed that one. i did lots of research before i
decided to bore you with my problem :slight_smile:

so it’s a known bug! was there a workaround, or do i have to wait for a
patch or something?

Tom W. wrote:

On 1/25/06, NoobSaibot [email protected] wrote:

unfortunately i get the same error message

Running out of ideas here, unfortunately. When you added a breakpoint
and inspected the project object, what output did you get?

Tom

Here’s the output for [@project]

=> [#<Project:0x37f48d8
@new_record=true,
@attributes={
“updated_at”=>nil,
“title”=>“Reisekosten”,
“starts_at”=>Wed Jan 25 17:25:00 Westeuropõische Normalzeit 2006,
“description”=>“Reisekosten”,
“ends_at”=>Wed Jan 25 17:25:00 Westeuropõische Normalzeit 2006,
“created_at”=>nil
}>
]

I wrote a not so little walkthrough on setting up Rails on the LiteSpeed
Webserver. I discovered LiteSpeed when they posted their SAPI interface
on
PHP Internals for inclusion in core a few weeks back. Although it’s a
commercial offering, their standard version is free and works great with
Rails and for you guys that still have legacy PHP code, well, you’ll
never
go back to Apache.

They have their own set of benchmarks, but who ever trusts those. I did
my
own testing (as should you if you are interested in speed) and this
combo
worked better for me than the others I tried.

The walkthrough can be found here:

http://www.railtie.net/articles/2006/01/21/up-and-running-in-the-speed-of-li
ght

BTW, I’m a programmer, not an author, so don’t expect this tutorial to
be on
the NYT Best-Sellers list.

Bob S.
http://www.railtie.net/

If anyone has any more information about this bug, it’d be great to
hear about it. There may be a workaround we can include in the
sqlserver adapter.

Tom

Tom W. wrote:

If anyone has any more information about this bug, it’d be great to
hear about it. There may be a workaround we can include in the
sqlserver adapter.

Tom

The same goes for the ODBC adapter, methinks.

Well, i hope there’ll be a patch to correct this bug, so i can
demonstrate the power of rails :slight_smile:

Noob,

One more attempt to try and fix this issue:

Could you replace the quote method in sqlserver_adapter.rb with this
and see if it helps at all:

def quote(value, column = nil)
case value
when String
if column && column.type == :binary
“’#{quote_string(column.class.string_to_binary(value))}’”
else
“’#{quote_string(value)}’”
end
when NilClass then “NULL”
when TrueClass then ‘1’
when FalseClass then ‘0’
when Float, Fixnum, Bignum then value.to_s
when Date, Time, DateTime then “convert(datetime,
'#{value.strftime(”%Y-%m-%d %H:%M:%S")}’, 121)"
else
“’#{quote_string(value.to_yaml)}’”
end
end

As I wrote earlier, when talking to SQL Server, it is safest to use the
SQL Server specific date/time formats.

dates: {d ‘yyyy-mm-dd’}, for example {d ‘2001-12-31’}
timestamps: {ts ‘yyyy-mm-dd hh:mm:ss’}, for example {ts ‘2001-12-31
00:00:00’}
times: {t ‘hh:mm:ss’}, etc.

I copied these from BigBold - Informasi Tentang Bisnis dan Marketing

BTW, the bug I mentioned in my earlier post was in the ODBC driver for
Sql Server 5 when 7 was about to be released, so that was quite some
time ago.

Regards,
Erik.

Tom W. schreef:

On 1/30/06, NoobSaibot [email protected] wrote:

Nope, what i get now is an infinite load of the page.
Curiouser and curiouser. I’ll try changing locale on my own sql
server and recreating the issue, but i wont have time to do this for a
couple of days. Sorry I can’t help more.

Tom