Showing posts with label bind. Show all posts
Showing posts with label bind. Show all posts

Thursday, March 22, 2012

Can't select a datetime field in a query without time portion

Hi,
I am doing some project with SQL Server 2000 and C#. I am using a
SELECT statement to get a column and to bind it to a dropdown list. The
column is a datetime format. I don't need time portion of it. Before I
tried any CONVERT functions my query looked like this:
SELECT DISTINCT DateEntered FROM TBL_PTM_Report
I can get the data this way but only with time portion in it. I read
about CONVERT but can't get it working. I am getting all kinds of error
messages from Visual Studio.
I tried the lowwoling:
SELECT COVVERT(CHAR(10), DateEntered, 101) FROM TBL_PTM_Report
It didn't work. I need data in the following format MM/DD/YYYY
Thank you,
Stan> SELECT COVVERT(CHAR(10), DateEntered, 101) FROM TBL_PTM_Report
CONVERT.
AMB
"suslishe@.mail.ru" wrote:

> Hi,
> I am doing some project with SQL Server 2000 and C#. I am using a
> SELECT statement to get a column and to bind it to a dropdown list. The
> column is a datetime format. I don't need time portion of it. Before I
> tried any CONVERT functions my query looked like this:
> SELECT DISTINCT DateEntered FROM TBL_PTM_Report
> I can get the data this way but only with time portion in it. I read
> about CONVERT but can't get it working. I am getting all kinds of error
> messages from Visual Studio.
> I tried the lowwoling:
>
> SELECT COVVERT(CHAR(10), DateEntered, 101) FROM TBL_PTM_Report
> It didn't work. I need data in the following format MM/DD/YYYY
> Thank you,
> Stan
>|||This was my typing mistake, sorry! The statement looks like this:
SELECT CONVERT(CHAR(10), DateEntered, 101) FROM TBL_PTM_Report|||I just ran this in query analyser and everything works! But Visual
Studio gives me an error.

Sunday, February 12, 2012

can't import .sql

i uses sql server 2005 express ,and type command as follow to import data : osql -E -S (local)\NetSDK -i InstNwnd.sql (as in Data Access - Bind Data in a ComboBox sample) but got an error :

D:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Samples\Setup>osql -E -S (lo
cal)\NetSDK -i InstNwnd.sql
[SQL Native Client]SQL Network Interfaces: Error Locating Server/Instance
Specified [xFFFFFFFF].
[SQL Native Client]Login timeout expired
[SQL Native Client]An error has occurred while establishing a connection to
the server. When connecting to SQL Server 2005, this failure may be caused by
the fact that under the default settings SQL Server does not allow remote connections.

what's is it ? and how i can import data ? thanks

Hi,

if you don′t have SQL Browser Service started, make sure that the instance you want to connect to is on the default port (1433) or you specify the portname after the instancename e.g. (local)\NETSDK,1477. If you have SQL Bworser service started, it should redirect you to the port of the named instance. If that all did not help, meke sure that you enabled remote connections in SQl Server. I have a screencast for this published on my site under Screencast > Enable remote connections.

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de

|||ya, the problems is the port , it's ok after i change it . Thanks|||As you are new to the forums, please make sure to mark an answer as correct after the problem is solved with the suggestion within a post.

HTH, Jens SUessmeyer.

http://www.sqlserver2005.de