Showing posts with label following. Show all posts
Showing posts with label following. Show all posts

Tuesday, March 27, 2012

DB access works in debug but fails when hosted

I have written a intranet page that writes some info into a sql database, basically following the 'SQL Server 2005 Express for Beginners' video.

When I debug the application from within 'Visual Web Develop 2005 express' it works fine entries are entered into the DB and I can then edit the db using the admin page.

But when I host the site using IIS I doesn't work, submissions to the database seem to fail I can see the DB in the admin page but if I try to edit them or delete them it fails.

What could I doing wrong could I be missing a setting in IIS? Any ideas??

Here's my webconfig if that helps at all:

<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<connectionStrings>
<add name="studentprofilesConnectionString1" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\studentprofiles.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<roleManager defaultProvider="AspNetWindowsTokenRoleProvider" />
<compilation debug="true" defaultLanguage="c#" /></system.web></configuration

There is a posibility that if SQL server is not configured to accept remote connection it may fail. To enable remote connection follow this steps

Under SQL2005 program menu follow configuration Tools =>SQL Server Surface Area Configuration => Select Server Surface Area Configuration for Services and Connections.

It will lead to a window with a treeview select Remote connections.Then Select Local and Remote Connections.

Now if the error is due to Remote configuration issue it will be resolved

DB access question

I have SQL 2000 server with 2 databases A&B
What would cause the following to occur:
We are connecting ODBC and Querry Analyzer
When person 1 is in DB A
person 2 cannot connect to DB B
When person 2 is in DB B
person 1 cannot connect to DB A
Thanks in advanceWhat error message do you get when person 1 or 2 "can't connect"? Do you
get failed login messages in the SQL errorlog (do you have failed login
logging turned on?)? Have you run SQL profiler against your server when
you're trying to do this (monitoring a whole bunch of security events like
Successful Login, Failed Login, etc., etc)?
Cheers,
Mike
"Jim Campau" <jim_campau@.bausch.com> wrote in message
news:ODpsdQCzEHA.1404@.TK2MSFTNGP11.phx.gbl...
>I have SQL 2000 server with 2 databases A&B
> What would cause the following to occur:
> We are connecting ODBC and Querry Analyzer
> When person 1 is in DB A
> person 2 cannot connect to DB B
> When person 2 is in DB B
> person 1 cannot connect to DB A
> Thanks in advance
>sql

DB access question

I have SQL 2000 server with 2 databases A&B
What would cause the following to occur:
We are connecting ODBC and Querry Analyzer
When person 1 is in DB A
person 2 cannot connect to DB B
When person 2 is in DB B
person 1 cannot connect to DB A
Thanks in advance
What error message do you get when person 1 or 2 "can't connect"? Do you
get failed login messages in the SQL errorlog (do you have failed login
logging turned on?)? Have you run SQL profiler against your server when
you're trying to do this (monitoring a whole bunch of security events like
Successful Login, Failed Login, etc., etc)?
Cheers,
Mike
"Jim Campau" <jim_campau@.bausch.com> wrote in message
news:ODpsdQCzEHA.1404@.TK2MSFTNGP11.phx.gbl...
>I have SQL 2000 server with 2 databases A&B
> What would cause the following to occur:
> We are connecting ODBC and Querry Analyzer
> When person 1 is in DB A
> person 2 cannot connect to DB B
> When person 2 is in DB B
> person 1 cannot connect to DB A
> Thanks in advance
>

DB access question

I have SQL 2000 server with 2 databases A&B
What would cause the following to occur:
We are connecting ODBC and Querry Analyzer
When person 1 is in DB A
person 2 cannot connect to DB B
When person 2 is in DB B
person 1 cannot connect to DB A
Thanks in advanceWhat error message do you get when person 1 or 2 "can't connect"? Do you
get failed login messages in the SQL errorlog (do you have failed login
logging turned on?)? Have you run SQL profiler against your server when
you're trying to do this (monitoring a whole bunch of security events like
Successful Login, Failed Login, etc., etc)?
--
Cheers,
Mike
"Jim Campau" <jim_campau@.bausch.com> wrote in message
news:ODpsdQCzEHA.1404@.TK2MSFTNGP11.phx.gbl...
>I have SQL 2000 server with 2 databases A&B
> What would cause the following to occur:
> We are connecting ODBC and Querry Analyzer
> When person 1 is in DB A
> person 2 cannot connect to DB B
> When person 2 is in DB B
> person 1 cannot connect to DB A
> Thanks in advance
>

DB Access from different m/c

when i access the database from different DB server getting the following error

Msg 18452, Sev 14, State 1, Line 1 : Login failed for user ''. The user is not associated with a trusted SQL Server connection. [SQLSTATE 28000]

Thanks,
Ravinder

Your SQL Server is set to Windows Authentication only. You need to logon with a user which has granted access to the server. You can′t provide a userId and passwort in the connecting string because this will be ognored in the case of Windows Auth. only. Another option would be, if feasable for your to switch the authentication mode to mixed.

HTH, jens Suessmeyer.

http://www.sqlserver2005.de

Wednesday, March 21, 2012

DateTime question

I'm trying to update a datetime field in my database with the current
date and time. The following command inserts the date as 1/13/06 when
most systems recognize 38728 as 1/11/06. Why does sql server 2005
increase this value by two days. The code that uses this database is
written in C# and makes heavy use of DateTime especially DateTime.Now,
which thinks 38728 is 1/11/06 so I'm not looking for a different way to
add this record, I want sql server to understand that 38728 is 1/11/06
and not 1/13/06.
Please help!
INSERT INTO [dbo].[Test]
([EID]
,[modifiedBy]
,[modifiedOn])
VALUES
(9999,
'TestHarness',
38728)What result does the following give you :-
select @.@.datefirst
Try SET @.@.DateFirst (two less than the result from above) before running
your insert
--
HTH. Ryan
"BetaD" <dhorth@.horth.com> wrote in message
news:1136994628.541049.108210@.g44g2000cwa.googlegroups.com...
> I'm trying to update a datetime field in my database with the current
> date and time. The following command inserts the date as 1/13/06 when
> most systems recognize 38728 as 1/11/06. Why does sql server 2005
> increase this value by two days. The code that uses this database is
> written in C# and makes heavy use of DateTime especially DateTime.Now,
> which thinks 38728 is 1/11/06 so I'm not looking for a different way to
> add this record, I want sql server to understand that 38728 is 1/11/06
> and not 1/13/06.
> Please help!
> INSERT INTO [dbo].[Test]
> ([EID]
> ,[modifiedBy]
> ,[modifiedOn])
> VALUES
> (9999,
> 'TestHarness',
> 38728)
>|||You don't use the product correctly. You express datetimes in SQL Server as a string, not as a
number. Unfortunately, SQL Server accepts a number (implicit datatype conversion) and thereby
exposes the internals of the product. And that happens to be different from some other systems, as
you have noticed. You cannot change the behavior in this regard. Check out:
http://www.karaszi.com/SQLServer/info_datetime.asp
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"BetaD" <dhorth@.horth.com> wrote in message
news:1136994628.541049.108210@.g44g2000cwa.googlegroups.com...
> I'm trying to update a datetime field in my database with the current
> date and time. The following command inserts the date as 1/13/06 when
> most systems recognize 38728 as 1/11/06. Why does sql server 2005
> increase this value by two days. The code that uses this database is
> written in C# and makes heavy use of DateTime especially DateTime.Now,
> which thinks 38728 is 1/11/06 so I'm not looking for a different way to
> add this record, I want sql server to understand that 38728 is 1/11/06
> and not 1/13/06.
> Please help!
> INSERT INTO [dbo].[Test]
> ([EID]
> ,[modifiedBy]
> ,[modifiedOn])
> VALUES
> (9999,
> 'TestHarness',
> 38728)
>|||Why not just take the c# datetime and convert to SqlDateTime and store that?
--
William Stacey [MVP]
"BetaD" <dhorth@.horth.com> wrote in message
news:1136994628.541049.108210@.g44g2000cwa.googlegroups.com...
> I'm trying to update a datetime field in my database with the current
> date and time. The following command inserts the date as 1/13/06 when
> most systems recognize 38728 as 1/11/06. Why does sql server 2005
> increase this value by two days. The code that uses this database is
> written in C# and makes heavy use of DateTime especially DateTime.Now,
> which thinks 38728 is 1/11/06 so I'm not looking for a different way to
> add this record, I want sql server to understand that 38728 is 1/11/06
> and not 1/13/06.
> Please help!
> INSERT INTO [dbo].[Test]
> ([EID]
> ,[modifiedBy]
> ,[modifiedOn])
> VALUES
> (9999,
> 'TestHarness',
> 38728)
>sql

DateTime question

I'm trying to update a datetime field in my database with the current
date and time. The following command inserts the date as 1/13/06 when
most systems recognize 38728 as 1/11/06. Why does sql server 2005
increase this value by two days. The code that uses this database is
written in C# and makes heavy use of DateTime especially DateTime.Now,
which thinks 38728 is 1/11/06 so I'm not looking for a different way to
add this record, I want sql server to understand that 38728 is 1/11/06
and not 1/13/06.
Please help!
INSERT INTO [dbo].[Test]
([EID]
,[modifiedBy]
,[modifiedOn])
VALUES
(9999,
'TestHarness',
38728)What result does the following give you :-
select @.@.datefirst
Try SET @.@.DateFirst (two less than the result from above) before running
your insert
HTH. Ryan
"BetaD" <dhorth@.horth.com> wrote in message
news:1136994628.541049.108210@.g44g2000cwa.googlegroups.com...
> I'm trying to update a datetime field in my database with the current
> date and time. The following command inserts the date as 1/13/06 when
> most systems recognize 38728 as 1/11/06. Why does sql server 2005
> increase this value by two days. The code that uses this database is
> written in C# and makes heavy use of DateTime especially DateTime.Now,
> which thinks 38728 is 1/11/06 so I'm not looking for a different way to
> add this record, I want sql server to understand that 38728 is 1/11/06
> and not 1/13/06.
> Please help!
> INSERT INTO [dbo].[Test]
> ([EID]
> ,[modifiedBy]
> ,[modifiedOn])
> VALUES
> (9999,
> 'TestHarness',
> 38728)
>|||You don't use the product correctly. You express datetimes in SQL Server as
a string, not as a
number. Unfortunately, SQL Server accepts a number (implicit datatype conver
sion) and thereby
exposes the internals of the product. And that happens to be different from
some other systems, as
you have noticed. You cannot change the behavior in this regard. Check out:
http://www.karaszi.com/SQLServer/info_datetime.asp
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"BetaD" <dhorth@.horth.com> wrote in message
news:1136994628.541049.108210@.g44g2000cwa.googlegroups.com...
> I'm trying to update a datetime field in my database with the current
> date and time. The following command inserts the date as 1/13/06 when
> most systems recognize 38728 as 1/11/06. Why does sql server 2005
> increase this value by two days. The code that uses this database is
> written in C# and makes heavy use of DateTime especially DateTime.Now,
> which thinks 38728 is 1/11/06 so I'm not looking for a different way to
> add this record, I want sql server to understand that 38728 is 1/11/06
> and not 1/13/06.
> Please help!
> INSERT INTO [dbo].[Test]
> ([EID]
> ,[modifiedBy]
> ,[modifiedOn])
> VALUES
> (9999,
> 'TestHarness',
> 38728)
>|||Why not just take the c# datetime and convert to SqlDateTime and store that?
William Stacey [MVP]
"BetaD" <dhorth@.horth.com> wrote in message
news:1136994628.541049.108210@.g44g2000cwa.googlegroups.com...
> I'm trying to update a datetime field in my database with the current
> date and time. The following command inserts the date as 1/13/06 when
> most systems recognize 38728 as 1/11/06. Why does sql server 2005
> increase this value by two days. The code that uses this database is
> written in C# and makes heavy use of DateTime especially DateTime.Now,
> which thinks 38728 is 1/11/06 so I'm not looking for a different way to
> add this record, I want sql server to understand that 38728 is 1/11/06
> and not 1/13/06.
> Please help!
> INSERT INTO [dbo].[Test]
> ([EID]
> ,[modifiedBy]
> ,[modifiedOn])
> VALUES
> (9999,
> 'TestHarness',
> 38728)
>

DateTime question

I'm trying to update a datetime field in my database with the current
date and time. The following command inserts the date as 1/13/06 when
most systems recognize 38728 as 1/11/06. Why does sql server 2005
increase this value by two days. The code that uses this database is
written in C# and makes heavy use of DateTime especially DateTime.Now,
which thinks 38728 is 1/11/06 so I'm not looking for a different way to
add this record, I want sql server to understand that 38728 is 1/11/06
and not 1/13/06.
Please help!
INSERT INTO [dbo].[Test]
([EID]
,[modifiedBy]
,[modifiedOn])
VALUES
(9999,
'TestHarness',
38728)
What result does the following give you :-
select @.@.datefirst
Try SET @.@.DateFirst (two less than the result from above) before running
your insert
HTH. Ryan
"BetaD" <dhorth@.horth.com> wrote in message
news:1136994628.541049.108210@.g44g2000cwa.googlegr oups.com...
> I'm trying to update a datetime field in my database with the current
> date and time. The following command inserts the date as 1/13/06 when
> most systems recognize 38728 as 1/11/06. Why does sql server 2005
> increase this value by two days. The code that uses this database is
> written in C# and makes heavy use of DateTime especially DateTime.Now,
> which thinks 38728 is 1/11/06 so I'm not looking for a different way to
> add this record, I want sql server to understand that 38728 is 1/11/06
> and not 1/13/06.
> Please help!
> INSERT INTO [dbo].[Test]
> ([EID]
> ,[modifiedBy]
> ,[modifiedOn])
> VALUES
> (9999,
> 'TestHarness',
> 38728)
>
|||You don't use the product correctly. You express datetimes in SQL Server as a string, not as a
number. Unfortunately, SQL Server accepts a number (implicit datatype conversion) and thereby
exposes the internals of the product. And that happens to be different from some other systems, as
you have noticed. You cannot change the behavior in this regard. Check out:
http://www.karaszi.com/SQLServer/info_datetime.asp
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"BetaD" <dhorth@.horth.com> wrote in message
news:1136994628.541049.108210@.g44g2000cwa.googlegr oups.com...
> I'm trying to update a datetime field in my database with the current
> date and time. The following command inserts the date as 1/13/06 when
> most systems recognize 38728 as 1/11/06. Why does sql server 2005
> increase this value by two days. The code that uses this database is
> written in C# and makes heavy use of DateTime especially DateTime.Now,
> which thinks 38728 is 1/11/06 so I'm not looking for a different way to
> add this record, I want sql server to understand that 38728 is 1/11/06
> and not 1/13/06.
> Please help!
> INSERT INTO [dbo].[Test]
> ([EID]
> ,[modifiedBy]
> ,[modifiedOn])
> VALUES
> (9999,
> 'TestHarness',
> 38728)
>
|||Why not just take the c# datetime and convert to SqlDateTime and store that?
William Stacey [MVP]
"BetaD" <dhorth@.horth.com> wrote in message
news:1136994628.541049.108210@.g44g2000cwa.googlegr oups.com...
> I'm trying to update a datetime field in my database with the current
> date and time. The following command inserts the date as 1/13/06 when
> most systems recognize 38728 as 1/11/06. Why does sql server 2005
> increase this value by two days. The code that uses this database is
> written in C# and makes heavy use of DateTime especially DateTime.Now,
> which thinks 38728 is 1/11/06 so I'm not looking for a different way to
> add this record, I want sql server to understand that 38728 is 1/11/06
> and not 1/13/06.
> Please help!
> INSERT INTO [dbo].[Test]
> ([EID]
> ,[modifiedBy]
> ,[modifiedOn])
> VALUES
> (9999,
> 'TestHarness',
> 38728)
>
sql

datetime procedure argument wont accept datetime value?

I am using Microsoft SQL Server Management Studio to connect to MSSQL 2005.... There is a stored procedure which has the following value amongst its parameters:

@.created_after datetime = null,

When I right-click the procedure and select Execute Stored Procedure, and enter a date like "23/01/2007 8:54:59 AM" into that field the following error is produced:

Msg 8114, Level 16, State 5, Procedure search, Line 0
Error converting data type nvarchar to datetime.
(1 row(s) affected)

As well as showing the following:

USE [FileStore]
GO

DECLARE @.return_value int

EXEC @.return_value = [dbo].[search]
@.created_after = N'23/01/2007 8:54:59 AM'

SELECT 'Return Value' = @.return_value

GO

Any idea why it will not accept my date value?

Any help would be appreciated ... Thank you :)

try input the datetime in universal format YYYYMMDD HH:MM:SS

Your system date format might not be DD/MM/YYYY|||You seem to be 100% correct! How can I change this?

datetime params quit working when i switched from ws to wcf

hi

HHello!, the following 3 webmethods still work after i switched them to WCF but now it never accepts my parameters. i didn't change anything in reporting services, but i have a feeling it's not sending the params to the service anymore.

is there an operation contract attribute change i need to make to require the datetime be provided by RS?

here's the schema provided by my serviec wsdl (the relevant portion)

- <xs:element name="EeoByAssignmentReport">

- <xs:complexType>

- <xs:sequence>

<xs:element minOccurs="0" name="start" type="xs:dateTime" />

<xs:element minOccurs="0" name="end" type="xs:dateTime" />

</xs:sequence>

</xs:complexType>

</xs:element>

- <xs:element name="EeoByAssignmentReportResponse">

- <xs:complexType>

- <xs:sequence>

- <xs:element minOccurs="0" name="EeoByAssignmentReportResult" nillable="true">

- <xs:complexType>

- <xs:annotation>

- <xs:appinfo>

<ActualType Name="DataSet" Namespace="http://schemas.datacontract.org/2004/07/System.Data" xmlns="http://schemas.microsoft.com/2003/10/Serialization/" />

</xs:appinfo>

</xs:annotation>

- <xs:sequence>

<xs:element ref="xs:schema" />

<xs:any />

</xs:sequence>

</xs:complexType>

</xs:element>

</xs:sequence>

</xs:complexType>

</xs:element>

- <xs:element name="EeoByPersonReport">

- <xs:complexType>

- <xs:sequence>

<xs:element minOccurs="0" name="start" type="xs:dateTime" />

<xs:element minOccurs="0" name="end" type="xs:dateTime" />

</xs:sequence>

</xs:complexType>

</xs:element>

- <xs:element name="EeoByPersonReportResponse">

- <xs:complexType>

- <xs:sequence>

- <xs:element minOccurs="0" name="EeoByPersonReportResult" nillable="true">

- <xs:complexType>

- <xs:annotation>

- <xs:appinfo>

<ActualType Name="DataSet" Namespace="http://schemas.datacontract.org/2004/07/System.Data" xmlns="http://schemas.microsoft.com/2003/10/Serialization/" />

</xs:appinfo>

</xs:annotation>

- <xs:sequence>

<xs:element ref="xs:schema" />

<xs:any />

</xs:sequence>

</xs:complexType>

</xs:element>

</xs:sequence>

</xs:complexType>

</xs:element>

- <xs:element name="EeoCountsReport">

- <xs:complexType>

- <xs:sequence>

<xs:element minOccurs="0" name="start" type="xs:dateTime" />

<xs:element minOccurs="0" name="end" type="xs:dateTime" />

</xs:sequence>

</xs:complexType>

</xs:element>

- <xs:element name="EeoCountsReportResponse">

- <xs:complexType>

- <xs:sequence>

- <xs:element minOccurs="0" name="EeoCountsReportResult" nillable="true">

- <xs:complexType>

- <xs:annotation>

- <xs:appinfo>

<ActualType Name="DataSet" Namespace="http://schemas.datacontract.org/2004/07/System.Data" xmlns="http://schemas.microsoft.com/2003/10/Serialization/" />

</xs:appinfo>

</xs:annotation>

- <xs:sequence>

<xs:element ref="xs:schema" />

<xs:any />

</xs:sequence>

</xs:complexType>

</xs:element>

</xs:sequence>

</xs:complexType>

</xs:element>

</xs:schema>

the reason i suspect it's not sending the data is because i have another method that takes a uint, and somehow the client proxy automatically generated a new bool property called <myuintname>Provided (or something like that) and now i always have to set that to true or it won't send the uint... I think that's what is happening here, except i have no way to set such a property since i'm sending pure primitaves no message contracts or anything.

i have to admit this behavior in the wcf is extremely frustrating, because all it does is zero out the field when you don't provide t he bool flag...which if i didn't want to send anything it would automatically be zero'd out because i didn't set it to anything.... makes no sense at all.

Monday, March 19, 2012

DateTime Parameter in URL

Hi Group,

How can I amend the following to pass the current date as the hidden parameter?
I tried Now() and Date() but this does not work

<form id="frmRender" action="http://Server1/ReportServer?/Reports/Charts/Pie" method="post"
target="_self">
<input type="hidden" name="rs:Command" value="Render&CreationDate">
<input type="hidden" name="rc:Toolbar" value="false">
<input type = "hidden" name=CreationDate value= '01/06/2004'>
<input type="submit" value="view report">
</form>

cheers

Try using javascript on the body onload event.

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
function setCreationDate()
{
var now = new Date();
document.Form1.CreationDate.value = now;
}
</SCRIPT>
</HEAD>
<body onload="setCreationDate()">
<form id="frmRender" action="http://Server1/ReportServer?/Reports/Charts/Pie" method="post"
target="_self">
<input type="hidden" name="rs:Command" value="Render&CreationDate">
<input type="hidden" name="rc:Toolbar" value="false">
<input type ="hidden" name=CreationDate value=''>
<input type="submit" value="view report">
</form>
</body>
</HTML>

datetime JDBC date conversion

I am writing a datetime field value to MS SQL Server 7 in the following manner
via a stored procedure:

// item to be written is originally a java.util.Date object
java.util.Date fromDate;
// I'm inserting it here into the database
cstmt.setTimestamp(8, new Timestamp(fromDate.getTime()));

// the record in the database appears as follows - as I wanted it to..
12/23/2004 4:30:43 AM

The problem is reading the date FROM the database back into ANY type of Java
Date-related object. No matter what I try, the hour/minutes/seconds are not
returned, and I desperately need the hour and minutes. I don't want to store
the hours and minutes in another field - it just causes more complications.
Does anyone out there know a way to get the ENTIRE date value out of the database?Hi

Are you saying that getTime() returns 00:00:00 ?

Posting your the code that tries to retrive this may help!

John

"billb" <kmilburn@.austin.rr.com> wrote in message
news:3561fddb.0410261050.6c8bafba@.posting.google.c om...
> I am writing a datetime field value to MS SQL Server 7 in the following
manner
> via a stored procedure:
> // item to be written is originally a java.util.Date object
> java.util.Date fromDate;
> // I'm inserting it here into the database
> cstmt.setTimestamp(8, new Timestamp(fromDate.getTime()));
> // the record in the database appears as follows - as I wanted it to..
> 12/23/2004 4:30:43 AM
> The problem is reading the date FROM the database back into ANY type of
Java
> Date-related object. No matter what I try, the hour/minutes/seconds are
not
> returned, and I desperately need the hour and minutes. I don't want to
store
> the hours and minutes in another field - it just causes more
complications.
> Does anyone out there know a way to get the ENTIRE date value out of the
database?|||
billb wrote:

> I am writing a datetime field value to MS SQL Server 7 in the following manner
> via a stored procedure:
> // item to be written is originally a java.util.Date object
> java.util.Date fromDate;
> // I'm inserting it here into the database
> cstmt.setTimestamp(8, new Timestamp(fromDate.getTime()));
> // the record in the database appears as follows - as I wanted it to..
> 12/23/2004 4:30:43 AM
> The problem is reading the date FROM the database back into ANY type of Java
> Date-related object. No matter what I try, the hour/minutes/seconds are not
> returned, and I desperately need the hour and minutes. I don't want to store
> the hours and minutes in another field - it just causes more complications.
> Does anyone out there know a way to get the ENTIRE date value out of the database?

Are you sure you tried getTimestamp()?
Joe Weinstein at BEA|||billb wrote:
> I am writing a datetime field value to MS SQL Server 7 in the following manner
> via a stored procedure:
> // item to be written is originally a java.util.Date object
> java.util.Date fromDate;
> // I'm inserting it here into the database
> cstmt.setTimestamp(8, new Timestamp(fromDate.getTime()));
> // the record in the database appears as follows - as I wanted it to..
> 12/23/2004 4:30:43 AM
> The problem is reading the date FROM the database back into ANY type of Java
> Date-related object. No matter what I try, the hour/minutes/seconds are not
> returned, and I desperately need the hour and minutes. I don't want to store
> the hours and minutes in another field - it just causes more complications.
> Does anyone out there know a way to get the ENTIRE date value out of the database?

Convert DATETIME into CHARATER using MS SQL finction is SELECT statement:

CONVERT ( VARCHAR( length ), some_datetime_colimn, <style> )

where <style> is magic number which defines format( 120 ~ yyyy-mm-dd HH:mi:ss);

get value from ResultSet as string and parse it using

java.text.DateFormat.parseDate(...)|||Hi,

Please use the following to construct a full date object from database date
field.

java.util.Date myDate = new
java.util.Date(myResultSet.getTimestamp("myDate").getTime());

I hope this will help ..

Regards,
Yasir

"billb" <kmilburn@.austin.rr.com> wrote in message
news:3561fddb.0410261050.6c8bafba@.posting.google.c om...
> I am writing a datetime field value to MS SQL Server 7 in the following
manner
> via a stored procedure:
> // item to be written is originally a java.util.Date object
> java.util.Date fromDate;
> // I'm inserting it here into the database
> cstmt.setTimestamp(8, new Timestamp(fromDate.getTime()));
> // the record in the database appears as follows - as I wanted it to..
> 12/23/2004 4:30:43 AM
> The problem is reading the date FROM the database back into ANY type of
Java
> Date-related object. No matter what I try, the hour/minutes/seconds are
not
> returned, and I desperately need the hour and minutes. I don't want to
store
> the hours and minutes in another field - it just causes more
complications.
> Does anyone out there know a way to get the ENTIRE date value out of the
database?

Datetime issue

In my DB, the date is in the following format : mm/dd/yyyy hh:mm:ss AM/PM
But wheni read the DB from the SqlDataReader, it returns the date in a different format : dd/mm/yyyy hh:mm:ss AM/PM
Why doesn't it return the date like it is in the DB?
For example, when i open the DB with Entreprise Manager : 5/25/2005 8:26:54 AM
But when i run the Debugger, it reads 25/05/2005 8:26:54 AM
Please help,
Thanks,
I think it may be your Windows regional setting and check you SQL Server configuration properties. Hope this helps.

Sunday, March 11, 2012

DateTime format problem

Hi,
I have a datetime field that store data in format like this following format:
2003-05-25 13:01:39.400
How can I change the format of the of the datetime to 13:01:39.400 only.
ThanksSELECT CONVERT(VARCHAR,GETDATE(),114)

This query will show you what all the datetime conversions look like. You can see why they look like they do by lookup up CONVERT in Books Online.

SET NOCOUNT ON

DECLARE
@.min INT,
@.max INT,
@.date DATETIME

SELECT
@.min = 1,
@.max = 131,
@.date = GETDATE()

SELECT @.date

WHILE @.min <= @.max
BEGIN

IF @.min BETWEEN 15 AND 19
OR @.min = 26
OR @.min BETWEEN 27 AND 99
OR @.min BETWEEN 115 AND 119
OR @.min BETWEEN 122 AND 125
OR @.min BETWEEN 127 AND 129
BEGIN
GOTO NEXT_LOOP
END

SELECT @.min, CONVERT(VARCHAR,@.date,@.min)

NEXT_LOOP:

SELECT @.min = @.min + 1
END

Datetime field - MS Access vs SQL Server

Hi all,
We were using MS Access as database and VB as frontend. Now we need
to support the database SQL Server also. We have following code which
works fine for MS Access.
For i = 0 To rsRecordset.Fields.Count - 1
Set objField = rsRecordset.Fields(i)
If (objField.Attributes And adFldIsNullable) =
adFldIsNullable Then
Select Case objField.Type
case adDate, adDBDate, adDBTime, adDBTimeStamp
If IsNull(objField.Value) Then
objField.Value = "#1/1/1900#"
--(1)
End If
end select
end if
next i
The select statement for that recordset is like this,
"Select max(Result_Date) as max_date from TestTable"
It was working fine with MS Access.
While executing statement(1) in SQL Server, it is throwing the error
"Multiple-step operation generated errors. Check each status value." I
found that the problem is using "max" function in the query(for that
field).
Can any one help for a work around for the above code to work in this
scenario for SQL Server.
Thanks in Advance.
Swapna.At a quick glance i would say get rid of the pound (#) signs in the date
http://sqlservercode.blogspot.com/
"swapna_munukoti@.yahoo.co.in" wrote:

> Hi all,
> We were using MS Access as database and VB as frontend. Now we need
> to support the database SQL Server also. We have following code which
> works fine for MS Access.
> For i = 0 To rsRecordset.Fields.Count - 1
> Set objField = rsRecordset.Fields(i)
> If (objField.Attributes And adFldIsNullable) =
> adFldIsNullable Then
> Select Case objField.Type
> case adDate, adDBDate, adDBTime, adDBTimeStamp
> If IsNull(objField.Value) Then
> objField.Value = "#1/1/1900#"
> --(1)
> End If
> end select
> end if
> next i
> The select statement for that recordset is like this,
> "Select max(Result_Date) as max_date from TestTable"
> It was working fine with MS Access.
> While executing statement(1) in SQL Server, it is throwing the error
> "Multiple-step operation generated errors. Check each status value." I
> found that the problem is using "max" function in the query(for that
> field).
> Can any one help for a work around for the above code to work in this
> scenario for SQL Server.
> Thanks in Advance.
> Swapna.
>|||> objField.Value = "#1/1/1900#"
How about
objField.Value = CDate("1900-01-01")|||All these things are working if the fleld is a direct one, as in this
query, "Select Result_Date as max_date from TestTable".
None of the above suggestions are working if the query has any field
with function like max() in it.|||You're trying to UPDATE a recordset that uses aggregates?
Have you considered using an UPDATE statement or a stored procedure?
<swapna_munukoti@.yahoo.co.in> wrote in message
news:1127364048.999418.224150@.g43g2000cwa.googlegroups.com...
> All these things are working if the fleld is a direct one, as in this
> query, "Select Result_Date as max_date from TestTable".
> None of the above suggestions are working if the query has any field
> with function like max() in it.
>|||<swapna_munukoti@.yahoo.co.in> wrote in message
news:1127364048.999418.224150@.g43g2000cwa.googlegroups.com...
> All these things are working if the fleld is a direct one, as in this
> query, "Select Result_Date as max_date from TestTable".
> None of the above suggestions are working if the query has any field
> with function like max() in it.
You cannot update a derived field of any sort, values returned by aggregate
functions included.
I'd be very much surprised to find that this truly worked with Jet -- I'd
easily believe it neglected to throw an error, but what row would it update?
-Mark

Thursday, March 8, 2012

datetime error

while executing the following statement:
select convert(datetime,'Nov 31, 2002 10:05pm')
got the following error:
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.

the datetime set is mdy
is there any way to make this work though this is not according to the iso standarts.

regards,
harsh.Does november contain 31 days ... hmm .. something is very wrong with your code
this works :-
select convert(datetime,'Nov 30, 2002 10:41PM',107)|||Originally posted by Enigma
Does november contain 31 days ... hmm .. something is very wrong with your code
this works :-
select convert(datetime,'Nov 30, 2002 10:41PM',107)

:D :D :D
how foolish of me!!
actually this was the input to a proc and the parameters were provided by the programmers, so i just tried to check with the same.
nways thnxs.
regards,
harsh.

datetime error

Hello,
Need some help with this:
I have SQL server 2000.
I run a query with the following where clause:
WHERE last_call_date >= '2006-06-01 00:00:00'
AND last_call_date <= '2006-06-02 23:59:59'
last_call_date is a datetime field.
I get results including these:
2006-06-03 00:00:00.000
why is this happening? I really don't know what to say... this for me is a
terrible thing.
Any help?
Thanks
Eduardo SicouretSorry this is the actual where clause:
WHERE last_call_date >= '2006-06-01 00:00:00.000'
AND last_call_date <= '2006-06-02 23:59:59.999'
Eduardo Sicouret
"Eduardo Sicouret" <esicouret> escribió en el mensaje
news:OD7WGb0iGHA.836@.TK2MSFTNGP02.phx.gbl...
> Hello,
> Need some help with this:
> I have SQL server 2000.
> I run a query with the following where clause:
> WHERE last_call_date >= '2006-06-01 00:00:00'
> AND last_call_date <= '2006-06-02 23:59:59'
> last_call_date is a datetime field.
> I get results including these:
> 2006-06-03 00:00:00.000
> why is this happening? I really don't know what to say... this for me is
> a terrible thing.
> Any help?
> Thanks
> Eduardo Sicouret
>|||Eduardo Sicouret wrote:
> Sorry this is the actual where clause:
> WHERE last_call_date >=3D '2006-06-01 00:00:00.000'
> AND last_call_date <=3D '2006-06-02 23:59:59.999'
> Eduardo Sicouret
> "Eduardo Sicouret" <esicouret> escribi=F3 en el mensaje
> news:OD7WGb0iGHA.836@.TK2MSFTNGP02.phx.gbl...
> > Hello,
> >
> > Need some help with this:
> >
> > I have SQL server 2000.
> >
> > I run a query with the following where clause:
> >
> > WHERE last_call_date >=3D '2006-06-01 00:00:00'
> > AND last_call_date <=3D '2006-06-02 23:59:59'
> >
> > last_call_date is a datetime field.
> >
> > I get results including these:
> >
> > 2006-06-03 00:00:00.000
> >
> > why is this happening? I really don't know what to say... this for me= is
> > a terrible thing.
> >
> > Any help?
> >
> > Thanks
> >
> > Eduardo Sicouret
> >
Use one of the following, otherwise the tail end of your date range
gets rounded up. The first example is the simplest and best IMO. If you
do use the format with both date and time then don't leave out the "T"
separator - it's important.
.=2E.
WHERE last_call_date >=3D '20060601'
AND last_call_date < '20060603'
.=2E.
WHERE last_call_date >=3D '2006-06-01T00:00:00.000'
AND last_call_date < '2006-06-03T00:00:00.000'
.=2E.
WHERE last_call_date >=3D '2006-06-01T00:00:00.000'
AND last_call_date <=3D '2006-06-02T23:59:59.997'
--
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--|||Try using CONVERT(DATETIME,last_call_date,20)
Jayesh
"Eduardo Sicouret" <esicouret> wrote in message
news:OD7WGb0iGHA.836@.TK2MSFTNGP02.phx.gbl...
> Hello,
> Need some help with this:
> I have SQL server 2000.
> I run a query with the following where clause:
> WHERE last_call_date >= '2006-06-01 00:00:00'
> AND last_call_date <= '2006-06-02 23:59:59'
> last_call_date is a datetime field.
> I get results including these:
> 2006-06-03 00:00:00.000
> why is this happening? I really don't know what to say... this for me is
> a terrible thing.
> Any help?
> Thanks
> Eduardo Sicouret
>

datetime error

Hello,
Need some help with this:
I have SQL server 2000.
I run a query with the following where clause:
WHERE last_call_date >= '2006-06-01 00:00:00'
AND last_call_date <= '2006-06-02 23:59:59'
last_call_date is a datetime field.
I get results including these:
2006-06-03 00:00:00.000
why is this happening? I really don't know what to say... this for me is a
terrible thing.
Any help?
Thanks
Eduardo SicouretSorry this is the actual where clause:
WHERE last_call_date >= '2006-06-01 00:00:00.000'
AND last_call_date <= '2006-06-02 23:59:59.999'
Eduardo Sicouret
"Eduardo Sicouret" <esicouret> escribi en el mensaje
news:OD7WGb0iGHA.836@.TK2MSFTNGP02.phx.gbl...
> Hello,
> Need some help with this:
> I have SQL server 2000.
> I run a query with the following where clause:
> WHERE last_call_date >= '2006-06-01 00:00:00'
> AND last_call_date <= '2006-06-02 23:59:59'
> last_call_date is a datetime field.
> I get results including these:
> 2006-06-03 00:00:00.000
> why is this happening? I really don't know what to say... this for me is
> a terrible thing.
> Any help?
> Thanks
> Eduardo Sicouret
>|||Eduardo Sicouret wrote:[vbcol=seagreen]
> Sorry this is the actual where clause:
> WHERE last_call_date >=3D '2006-06-01 00:00:00.000'
> AND last_call_date <=3D '2006-06-02 23:59:59.999'
> Eduardo Sicouret
> "Eduardo Sicouret" <esicouret> escribi=F3 en el mensaje
> news:OD7WGb0iGHA.836@.TK2MSFTNGP02.phx.gbl...
is[vbcol=seagreen]
Use one of the following, otherwise the tail end of your date range
gets rounded up. The first example is the simplest and best IMO. If you
do use the format with both date and time then don't leave out the "T"
separator - it's important.
.=2E.
WHERE last_call_date >=3D '20060601'
AND last_call_date < '20060603'
.=2E.
WHERE last_call_date >=3D '2006-06-01T00:00:00.000'
AND last_call_date < '2006-06-03T00:00:00.000'
.=2E.
WHERE last_call_date >=3D '2006-06-01T00:00:00.000'
AND last_call_date <=3D '2006-06-02T23:59:59.997'
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--|||Try using CONVERT(DATETIME,last_call_date,20)
Jayesh
"Eduardo Sicouret" <esicouret> wrote in message
news:OD7WGb0iGHA.836@.TK2MSFTNGP02.phx.gbl...
> Hello,
> Need some help with this:
> I have SQL server 2000.
> I run a query with the following where clause:
> WHERE last_call_date >= '2006-06-01 00:00:00'
> AND last_call_date <= '2006-06-02 23:59:59'
> last_call_date is a datetime field.
> I get results including these:
> 2006-06-03 00:00:00.000
> why is this happening? I really don't know what to say... this for me is
> a terrible thing.
> Any help?
> Thanks
> Eduardo Sicouret
>

datetime conversion question

Using SQL2005 DTS - I am trying to import data from a CSV file into a table
created with the following
CREATE TABLE [maint].[dbo].[SpaceAnalysis_v2] (
[Date-Time] datetime,
[Server] text,
[Drive] text,
[Drive Size] numeric(29,0),
[Space Free] numeric(29,0)
)
the first field is date and time and looks like this >>
09/20/2006 06:30:03 PM
But no matter what I try to use for a final field format the result of that
data after it's imported displays the same time for every record >> 12:00:00
AM <<. The date comes through fine, but it just does not seem to recognize
the time. What do I need to do to get the time to be imported correctly ?It appears that the time is not included as part of the date data.
Is the date/time field enclosed in single quotes? (Such as: '09/20/2006
06:30:03 PM') This is a non-standard date format, having two spaces between
the date and time portions, as well as a space between the time and the
AM/PM indicator.
Please post an EXACT excerpt from the import file so that we can visually
see the data to determine if there are problems that are causing a
'mis-load'.
--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
You can't help someone get up a hill without getting a little closer to the
top yourself.
- H. Norman Schwarzkopf
"WANNABE" <breichenbach AT istate DOT com> wrote in message
news:eXDUZT1AHHA.4472@.TK2MSFTNGP03.phx.gbl...
> Using SQL2005 DTS - I am trying to import data from a CSV file into a
> table created with the following
> CREATE TABLE [maint].[dbo].[SpaceAnalysis_v2] (
> [Date-Time] datetime,
> [Server] text,
> [Drive] text,
> [Drive Size] numeric(29,0),
> [Space Free] numeric(29,0)
> )
> the first field is date and time and looks like this >>
> 09/20/2006 06:30:03 PM
> But no matter what I try to use for a final field format the result of
> that data after it's imported displays the same time for every record >>
> 12:00:00 AM <<. The date comes through fine, but it just does not seem
> to recognize the time. What do I need to do to get the time to be
> imported correctly ?
>|||As I paste this in here I just realized that my first post was not
absolutely correct, sorry I was looking at the file through excel.
Thanks for your time Arnie, here are the first 2 lines as
displayed using notepad>>
9/19/2006 16:50,EXCEDE,C,36265226240,14397304832
9/19/2006 16:50,EXCEDE,D,147000000000,41808166912
======================================"Arnie Rowland" <arnie@.1568.com> wrote in message
news:O8sLGE3AHHA.3560@.TK2MSFTNGP04.phx.gbl...
> It appears that the time is not included as part of the date data.
> Is the date/time field enclosed in single quotes? (Such as: '09/20/2006
> 06:30:03 PM') This is a non-standard date format, having two spaces
> between the date and time portions, as well as a space between the time
> and the AM/PM indicator.
> Please post an EXACT excerpt from the import file so that we can visually
> see the data to determine if there are problems that are causing a
> 'mis-load'.
> --
> Arnie Rowland, Ph.D.
> Westwood Consulting, Inc
> Most good judgment comes from experience.
> Most experience comes from bad judgment.
> - Anonymous
> You can't help someone get up a hill without getting a little closer to
> the top yourself.
> - H. Norman Schwarzkopf
>
> "WANNABE" <breichenbach AT istate DOT com> wrote in message
> news:eXDUZT1AHHA.4472@.TK2MSFTNGP03.phx.gbl...
>> Using SQL2005 DTS - I am trying to import data from a CSV file into a
>> table created with the following
>> CREATE TABLE [maint].[dbo].[SpaceAnalysis_v2] (
>> [Date-Time] datetime,
>> [Server] text,
>> [Drive] text,
>> [Drive Size] numeric(29,0),
>> [Space Free] numeric(29,0)
>> )
>> the first field is date and time and looks like this >>
>> 09/20/2006 06:30:03 PM
>> But no matter what I try to use for a final field format the result of
>> that data after it's imported displays the same time for every record >>
>> 12:00:00 AM <<. The date comes through fine, but it just does not seem
>> to recognize the time. What do I need to do to get the time to be
>> imported correctly ?
>

Wednesday, March 7, 2012

DateTime again - how to us the time aswell as date

Hi All,

I have a SQl Statemnent ... AND dbStartDateTime >= 27/12/2003 19:00:00 ... and get the following error

Incorrect syntax near '19'

I dont understand why it wouldnt like this as this is how it is stored in the database?

I have looked for answers but most people seem to want ot use DateTime without the time

Thanks in advance

LeeYou should enclose the datetime value in single quotes.

 AND dbStartDateTime >= '27/12/2003 19:00:00'

Terri|||Thanks for your help Terri,

I need to re-read the chapter in my book! about syntax etc

Lee