Showing posts with label select. Show all posts
Showing posts with label select. Show all posts

Tuesday, March 27, 2012

Connecting to SQL server

Select * from ServerName.DatabaseName.OwnerOrSchema.Objectname

I tyied the way given above.But when im going to run it on query analizer it gives an error massege saying that

"Server 'JOY' is not configured for DATA ACCESS.'

How can i configure the particuler sever.

Thanks

Set the server configuration to allow remote connections.

Monday, March 19, 2012

Connecting to localhost Problems?

I'm taking a .NET class and I have SQL Server 2005 installed on my
machine. When I go into Studio and then select Server Explorer and try
to add a new Connection, it seems to bomb out when I type in
'localhost' for the server name. It doesn't come back with anything
for the DBS. Is there something I need to do to get my machine to
understand 'localhost'?"Rick" <rlc_60504@.yahoo.comwrote in message
news:1162528400.038379.136840@.h54g2000cwb.googlegr oups.com...

Quote:

Originally Posted by

I'm taking a .NET class and I have SQL Server 2005 installed on my
machine. When I go into Studio and then select Server Explorer and try
to add a new Connection, it seems to bomb out when I type in
'localhost' for the server name. It doesn't come back with anything
for the DBS. Is there something I need to do to get my machine to
understand 'localhost'?


Very likely you have SQL 2005 installed as a named instance, so you have to
specifically provide the hostname AND isntance name.

Quote:

Originally Posted by

>

Saturday, February 25, 2012

Connecting the ASP.Net to a DB using SQL Query

I have a SQL query that I think it wont work it's:

SELECT break_time, break_rep_no, break_count, break_update_count, break_type, break_group
FROM breaks
WHERE (break_date = @.p1) AND (break_group = @.p2) AND (break_time > @.p3) OR
(break_time < @.P4)
ORDER BY break_time

When I insert this parameters:

@.p1= 7/21/2004
@.p2= 0
@.p3= 9:00 AM
@.p4= 3:00 PM

I get these results:
Break_time rep_no count ucount break_type break_group
9:00:00 AM____2____2_____0________2_________0
9:00:00 AM____2____2_____1________1_________0
10:00:00 AM___1____2_____0________2_________2
11:20:00 AM___2____1_____0________2_________2
1:00:00 PM____2____2_____1________1_________0

Which if you notice not the result I expect look at the (break_group) Column you will find that it brings 0's in addition to 2 which is not expected to appears?

I'm using this query in ASP.Net page Under VB.Net

Me.SqlComm_Chk_Group.Parameters(0).Value = System.DateTime.Today
Me.SqlComm_Chk_Group.Parameters(1).Value = 0
Me.SqlComm_Chk_Group.Parameters(2).Value = tFrom.AddMinutes(59).ToShortTimeString()
Me.SqlComm_Chk_Group.Parameters(3).Value = tTo.AddMinutes(-59).ToShortTimeString()

dr = Me.SqlComm_Chk_Group.ExecuteReader

While dr.Read
tBreakTime = dr(0)
iRepNo = dr(1)
iBreakCount = dr(2)
iBreakUCount = dr(3)
iBreakType = dr(4)
iBreakGreoup = dr(5)

Call Engine(tBreakTime, tFrom, iBreakType, False, iRepNo)
End While
dr.Close()

Where is the problem PLAES?
Thank youParenthesize.


SELECT break_time, break_rep_no, break_count, break_update_count, break_type, break_group
FROM breaks
WHERE (break_date = @.p1) AND (break_group = @.p2) AND ((break_time > @.p3) OR
(break_time < @.P4))
ORDER BY break_time

Even now, I am not sure the code will do what you are looking to do.|||Why I did it before and it works I even try it with OleDB with MSAccess DB But I'm not understand why its not working here every thing seems to be correct|||Depending upon the data in the db and the times you pass, it might APPEAR to work for some data.

connecting sql server

i created a database, when i query a simple select statement , i get an
error:
"Cannot open database requested in login 'XYZ_Database'.
Login fails, Login failed for user 'sa''
But when i change , the database name to Northwind, it works.
i checked that user rights of 'sa' for XYZ_database and Northwind are the
same?
i get the same error, when i used integrated security to connect too.
what would be the case here?
Hi,
It seems the database creator/owner might be some other user.
Execute the below command to check the database owner:-
sp_helpdb 'XYZ_Database'
If the owner is a non SA user , then change the database owner using:-
sp_changedbowner system procedure (Refer books online for information)
Thanks
Hari
MCDBA
"e-mid" <someone@.somewhere> wrote in message
news:#uip9U6VEHA.208@.TK2MSFTNGP10.phx.gbl...
> i created a database, when i query a simple select statement , i get an
> error:
> "Cannot open database requested in login 'XYZ_Database'.
> Login fails, Login failed for user 'sa''
>
> But when i change , the database name to Northwind, it works.
> i checked that user rights of 'sa' for XYZ_database and Northwind are the
> same?
> i get the same error, when i used integrated security to connect too.
> what would be the case here?
>
|||Hari;
user of the database seems to be sa; here is the properties of the database:
"XYZ_database 3.00 MB sa 7 Jun 21 2004 Status=ONLINE,
Updateability=READ_WRITE, UserAccess=MULTI_USER, Recovery=FULL,
Version=539, Collation=Latin1_General_CI_AS, SQLSortOrder=0,
IsTornPageDetectionEnabled, IsAutoCreateStatistics, IsAutoUpdateStatistics
80"
what else can be the problem?
"Hari Prasad" <hari_prasad_k@.hotmail.com> wrote in message
news:#Sh3WY6VEHA.1144@.TK2MSFTNGP10.phx.gbl...[vbcol=seagreen]
> Hi,
> It seems the database creator/owner might be some other user.
> Execute the below command to check the database owner:-
> sp_helpdb 'XYZ_Database'
> If the owner is a non SA user , then change the database owner using:-
> sp_changedbowner system procedure (Refer books online for information)
> Thanks
> Hari
> MCDBA
>
>
> "e-mid" <someone@.somewhere> wrote in message
> news:#uip9U6VEHA.208@.TK2MSFTNGP10.phx.gbl...
the
>
|||i am becoming insane.
i did not change even a letter but it is working now ?!
"e-mid" <someone@.somewhere> wrote in message
news:u7BQSe6VEHA.2520@.TK2MSFTNGP12.phx.gbl...
> Hari;
> user of the database seems to be sa; here is the properties of the
database:[vbcol=seagreen]
> "XYZ_database 3.00 MB sa 7 Jun 21 2004 Status=ONLINE,
> Updateability=READ_WRITE, UserAccess=MULTI_USER, Recovery=FULL,
> Version=539, Collation=Latin1_General_CI_AS, SQLSortOrder=0,
> IsTornPageDetectionEnabled, IsAutoCreateStatistics, IsAutoUpdateStatistics
> 80"
> what else can be the problem?
> "Hari Prasad" <hari_prasad_k@.hotmail.com> wrote in message
> news:#Sh3WY6VEHA.1144@.TK2MSFTNGP10.phx.gbl...
an
> the
>
|||Good.
Thanks
Hari
MCDBA
"e-mid" <someone@.somewhere> wrote in message
news:OFRlQt6VEHA.2408@.tk2msftngp13.phx.gbl...[vbcol=seagreen]
> i am becoming insane.
> i did not change even a letter but it is working now ?!
>
> "e-mid" <someone@.somewhere> wrote in message
> news:u7BQSe6VEHA.2520@.TK2MSFTNGP12.phx.gbl...
> database:
IsAutoUpdateStatistics[vbcol=seagreen]
> an
are[vbcol=seagreen]
too.
>

connecting sql server

i created a database, when i query a simple select statement , i get an
error:
"Cannot open database requested in login 'XYZ_Database'.
Login fails, Login failed for user 'sa''
But when i change , the database name to Northwind, it works.
i checked that user rights of 'sa' for XYZ_database and Northwind are the
same?
i get the same error, when i used integrated security to connect too.
what would be the case here?Hi,
It seems the database creator/owner might be some other user.
Execute the below command to check the database owner:-
sp_helpdb 'XYZ_Database'
If the owner is a non SA user , then change the database owner using:-
sp_changedbowner system procedure (Refer books online for information)
Thanks
Hari
MCDBA
"e-mid" <someone@.somewhere> wrote in message
news:#uip9U6VEHA.208@.TK2MSFTNGP10.phx.gbl...
> i created a database, when i query a simple select statement , i get an
> error:
> "Cannot open database requested in login 'XYZ_Database'.
> Login fails, Login failed for user 'sa''
>
> But when i change , the database name to Northwind, it works.
> i checked that user rights of 'sa' for XYZ_database and Northwind are the
> same?
> i get the same error, when i used integrated security to connect too.
> what would be the case here?
>|||Hari;
user of the database seems to be sa; here is the properties of the database:
"XYZ_database 3.00 MB sa 7 Jun 21 2004 Status=ONLINE,
Updateability=READ_WRITE, UserAccess=MULTI_USER, Recovery=FULL,
Version=539, Collation=Latin1_General_CI_AS, SQLSortOrder=0,
IsTornPageDetectionEnabled, IsAutoCreateStatistics, IsAutoUpdateStatistics
80"
what else can be the problem?
"Hari Prasad" <hari_prasad_k@.hotmail.com> wrote in message
news:#Sh3WY6VEHA.1144@.TK2MSFTNGP10.phx.gbl...
> Hi,
> It seems the database creator/owner might be some other user.
> Execute the below command to check the database owner:-
> sp_helpdb 'XYZ_Database'
> If the owner is a non SA user , then change the database owner using:-
> sp_changedbowner system procedure (Refer books online for information)
> Thanks
> Hari
> MCDBA
>
>
> "e-mid" <someone@.somewhere> wrote in message
> news:#uip9U6VEHA.208@.TK2MSFTNGP10.phx.gbl...
> > i created a database, when i query a simple select statement , i get an
> > error:
> >
> > "Cannot open database requested in login 'XYZ_Database'.
> > Login fails, Login failed for user 'sa''
> >
> >
> > But when i change , the database name to Northwind, it works.
> >
> > i checked that user rights of 'sa' for XYZ_database and Northwind are
the
> > same?
> >
> > i get the same error, when i used integrated security to connect too.
> >
> > what would be the case here?
> >
> >
>|||i am becoming insane.
i did not change even a letter but it is working now '!
"e-mid" <someone@.somewhere> wrote in message
news:u7BQSe6VEHA.2520@.TK2MSFTNGP12.phx.gbl...
> Hari;
> user of the database seems to be sa; here is the properties of the
database:
> "XYZ_database 3.00 MB sa 7 Jun 21 2004 Status=ONLINE,
> Updateability=READ_WRITE, UserAccess=MULTI_USER, Recovery=FULL,
> Version=539, Collation=Latin1_General_CI_AS, SQLSortOrder=0,
> IsTornPageDetectionEnabled, IsAutoCreateStatistics, IsAutoUpdateStatistics
> 80"
> what else can be the problem?
> "Hari Prasad" <hari_prasad_k@.hotmail.com> wrote in message
> news:#Sh3WY6VEHA.1144@.TK2MSFTNGP10.phx.gbl...
> > Hi,
> >
> > It seems the database creator/owner might be some other user.
> >
> > Execute the below command to check the database owner:-
> >
> > sp_helpdb 'XYZ_Database'
> >
> > If the owner is a non SA user , then change the database owner using:-
> >
> > sp_changedbowner system procedure (Refer books online for information)
> >
> > Thanks
> > Hari
> > MCDBA
> >
> >
> >
> >
> > "e-mid" <someone@.somewhere> wrote in message
> > news:#uip9U6VEHA.208@.TK2MSFTNGP10.phx.gbl...
> > > i created a database, when i query a simple select statement , i get
an
> > > error:
> > >
> > > "Cannot open database requested in login 'XYZ_Database'.
> > > Login fails, Login failed for user 'sa''
> > >
> > >
> > > But when i change , the database name to Northwind, it works.
> > >
> > > i checked that user rights of 'sa' for XYZ_database and Northwind are
> the
> > > same?
> > >
> > > i get the same error, when i used integrated security to connect too.
> > >
> > > what would be the case here?
> > >
> > >
> >
> >
>|||Good. :)
Thanks
Hari
MCDBA
"e-mid" <someone@.somewhere> wrote in message
news:OFRlQt6VEHA.2408@.tk2msftngp13.phx.gbl...
> i am becoming insane.
> i did not change even a letter but it is working now '!
>
> "e-mid" <someone@.somewhere> wrote in message
> news:u7BQSe6VEHA.2520@.TK2MSFTNGP12.phx.gbl...
> > Hari;
> >
> > user of the database seems to be sa; here is the properties of the
> database:
> >
> > "XYZ_database 3.00 MB sa 7 Jun 21 2004 Status=ONLINE,
> >
> > Updateability=READ_WRITE, UserAccess=MULTI_USER, Recovery=FULL,
> >
> > Version=539, Collation=Latin1_General_CI_AS, SQLSortOrder=0,
> >
> > IsTornPageDetectionEnabled, IsAutoCreateStatistics,
IsAutoUpdateStatistics
> > 80"
> >
> > what else can be the problem?
> >
> > "Hari Prasad" <hari_prasad_k@.hotmail.com> wrote in message
> > news:#Sh3WY6VEHA.1144@.TK2MSFTNGP10.phx.gbl...
> > > Hi,
> > >
> > > It seems the database creator/owner might be some other user.
> > >
> > > Execute the below command to check the database owner:-
> > >
> > > sp_helpdb 'XYZ_Database'
> > >
> > > If the owner is a non SA user , then change the database owner using:-
> > >
> > > sp_changedbowner system procedure (Refer books online for information)
> > >
> > > Thanks
> > > Hari
> > > MCDBA
> > >
> > >
> > >
> > >
> > > "e-mid" <someone@.somewhere> wrote in message
> > > news:#uip9U6VEHA.208@.TK2MSFTNGP10.phx.gbl...
> > > > i created a database, when i query a simple select statement , i get
> an
> > > > error:
> > > >
> > > > "Cannot open database requested in login 'XYZ_Database'.
> > > > Login fails, Login failed for user 'sa''
> > > >
> > > >
> > > > But when i change , the database name to Northwind, it works.
> > > >
> > > > i checked that user rights of 'sa' for XYZ_database and Northwind
are
> > the
> > > > same?
> > > >
> > > > i get the same error, when i used integrated security to connect
too.
> > > >
> > > > what would be the case here?
> > > >
> > > >
> > >
> > >
> >
> >
>

connecting sql server

i created a database, when i query a simple select statement , i get an
error:
"Cannot open database requested in login 'XYZ_Database'.
Login fails, Login failed for user 'sa''
But when i change , the database name to Northwind, it works.
i checked that user rights of 'sa' for XYZ_database and Northwind are the
same?
i get the same error, when i used integrated security to connect too.
what would be the case here?Hi,
It seems the database creator/owner might be some other user.
Execute the below command to check the database owner:-
sp_helpdb 'XYZ_Database'
If the owner is a non SA user , then change the database owner using:-
sp_changedbowner system procedure (Refer books online for information)
Thanks
Hari
MCDBA
"e-mid" <someone@.somewhere> wrote in message
news:#uip9U6VEHA.208@.TK2MSFTNGP10.phx.gbl...
> i created a database, when i query a simple select statement , i get an
> error:
> "Cannot open database requested in login 'XYZ_Database'.
> Login fails, Login failed for user 'sa''
>
> But when i change , the database name to Northwind, it works.
> i checked that user rights of 'sa' for XYZ_database and Northwind are the
> same?
> i get the same error, when i used integrated security to connect too.
> what would be the case here?
>|||Hari;
user of the database seems to be sa; here is the properties of the database:
"XYZ_database 3.00 MB sa 7 Jun 21 2004 Status=ONLINE,
Updateability=READ_WRITE, UserAccess=MULTI_USER, Recovery=FULL,
Version=539, Collation=Latin1_General_CI_AS, SQLSortOrder=0,
IsTornPageDetectionEnabled, IsAutoCreateStatistics, IsAutoUpdateStatistics
80"
what else can be the problem?
"Hari Prasad" <hari_prasad_k@.hotmail.com> wrote in message
news:#Sh3WY6VEHA.1144@.TK2MSFTNGP10.phx.gbl...
> Hi,
> It seems the database creator/owner might be some other user.
> Execute the below command to check the database owner:-
> sp_helpdb 'XYZ_Database'
> If the owner is a non SA user , then change the database owner using:-
> sp_changedbowner system procedure (Refer books online for information)
> Thanks
> Hari
> MCDBA
>
>
> "e-mid" <someone@.somewhere> wrote in message
> news:#uip9U6VEHA.208@.TK2MSFTNGP10.phx.gbl...
the[vbcol=seagreen]
>|||i am becoming insane.
i did not change even a letter but it is working now '!
"e-mid" <someone@.somewhere> wrote in message
news:u7BQSe6VEHA.2520@.TK2MSFTNGP12.phx.gbl...
> Hari;
> user of the database seems to be sa; here is the properties of the
database:
> "XYZ_database 3.00 MB sa 7 Jun 21 2004 Status=ONLINE,
> Updateability=READ_WRITE, UserAccess=MULTI_USER, Recovery=FULL,
> Version=539, Collation=Latin1_General_CI_AS, SQLSortOrder=0,
> IsTornPageDetectionEnabled, IsAutoCreateStatistics, IsAutoUpdateStatistics
> 80"
> what else can be the problem?
> "Hari Prasad" <hari_prasad_k@.hotmail.com> wrote in message
> news:#Sh3WY6VEHA.1144@.TK2MSFTNGP10.phx.gbl...
an[vbcol=seagreen]
> the
>|||Good.
Thanks
Hari
MCDBA
"e-mid" <someone@.somewhere> wrote in message
news:OFRlQt6VEHA.2408@.tk2msftngp13.phx.gbl...
> i am becoming insane.
> i did not change even a letter but it is working now '!
>
> "e-mid" <someone@.somewhere> wrote in message
> news:u7BQSe6VEHA.2520@.TK2MSFTNGP12.phx.gbl...
> database:
IsAutoUpdateStatistics[vbcol=seagreen]
> an
are[vbcol=seagreen]
too.[vbcol=seagreen]
>