Showing posts with label invalid. Show all posts
Showing posts with label invalid. Show all posts

Wednesday, March 21, 2012

Oledb Provider having problem in MS SQL Server 2005

Hi,

I try to access the table "UserGroup" in my local sql server 2005 database. However I get this error message
"Invalid object name 'UserGroup'. "

I'm using MS Visual Studio 2005 and MS Sql Server 2005. I did install the latest Sql Native. In fact I just migrate from ASP.NET to ASP.NET 2.0 . It is working if my connection string is point to my "online host" without any error.

'Online Connection String - Working
<addkey="OLEDB"value="Provider=SQLOLEDB.1;Persist Security Info=False;User ID=abc;Initial Catalog=mydatabase_db;Data Source=xxx.xx.xx.xx,xxxx; Password=xxxx;Connect Timeout=3600"/>

'Local Connection String - Not working
(SQL Authentication)
<addkey="OLEDB"value="Provider=SQLNCLI;Trusted_Connection=No;UID=calvin;Initial Catalog=mydatabase_db;Data Source=CALVINNB; Password=xxxxxx"/>
OR
(Windows Authentication)
<addkey="OLEDB"value="Provider=SQLNCLI;Server=CALVINNB;Database=mydatabase_db;Trusted_Connection=yes"/
Is the Oledb provider having problem in MS SQL Server 2005?

Any help would be more appreciate.

Calvin


First thing I would try it to make sure you do have a table named UserGroup, and also try prefixing with with the owner.

Next, you should be using the SQL provider and not the OLEDB providers for SQL Server.

|||Yes, I do have a table named UserGroup. If I change the OLEDB provider to SQL provider, then I have a lot of code need to be change and debug. Is there any way to solve this problem? And I don't understand why I use my "Online" connection string(bottom) without error? Even the provider isSQLOLEDB.1?

<addkey="OLEDB"value="Provider=SQLOLEDB.1;Persist Security Info=False;User ID=xxx;Initial Catalog=mydatabase_db;Data Source=xxx.xx.xx.xx,xxxx; Password=xxxxxx;Connect Timeout=3600"/>

The difference to my local connection is just the "UID", "Password" and Data Source only. I'm sure that the login account for local is created perfectly. The host and my computer also using MS SQL Server 2005.

|||

EDUStreet:

Yes, I do have a table named UserGroup. If I change the OLEDB provider to SQL provider, then I have a lot of code need to be change and debug.

OLEDB provider is meant to be used for older data sources. For SQL Server 7.0+ you should really be using the SQL Providers, that is what it is there for. In terms of coding changes there should not be too many apart from renaming all the declarations and instantiations from Oledb to Sql.

One of the best ways to make sure you got the right connection string is to drag and drop something like a gridview or sqldatasource and go through the wizard to connect to your datasouce and use the auto generated connection string

Here is a web site that has all connection string formats

http://www.connectionstrings.com/?carrier=sqlserver2005

|||

Finally, I change all the code which is from OLEDB provider to SQL provider

This is the connection string i'm using now.

<addkey="OLEDB"value="User ID=xxxx;Initial Catalog=mydatabase_db;Data Source=xxx.xx.xx.xx,xxxx; Password=xxxx"/>

|||

EDUStreet:

"The ConnectionString property has not been initialized. "

When you create the SqlConnection object you need to supply the connection string. Please ensure you have done this.

|||

Thanks Jimmy :)

Monday, March 12, 2012

OLE/DB provider returned message: Invalid authorization specification

Hello,
I'm trying to import a table from a MSDE database (databaseB) into a SQL
server database (database A).
Using to following sql statement:
insert tableA
select a.*
from openrowset(sqloledb,'Provider=sqloledb;Password=pw d;User ID=usr;Initial
Catalog=databaseA;Data Source=server', select * from [dbo].[tableB]') as a
I'm getting the following error:
[OLE/DB provider returned message: Invalid authorization specification]
[OLE/DB provider returned message: Invalid connection string attribute]
OLE DB error trace [OLE/DB Provider 'SQLOLEDB' IDBInitialize::Initialize
returned 0x80004005: ].
Everything runs fine if I use integrated security!? The used usr/pwd is a
MSDE login account.
A UDL file connection test directly to the MSDE database runs fine.
Thanx!
CHU! Eric
Hello Eric,
I have reproduced the issue on my side. Based on my research, the following
command works well:
insert into tableA
SELECT a.*
FROM OPENROWSET('SQLOLEDB','sophietest\msdeinstance';'s a';'password',
'SELECT * FROM test.dbo.tableB ') AS a
GO
or
insert into tableA
select a.*
from
openrowset('sqloledb','Provider=sqloledb;UID=sa;PW D=password;Database=test;S
erver=sophietest\msdeinstance', 'select * from [dbo].[tableB]') as a
Therefore, I recommend you perform the following commands:
1. Make sure the Authentication Mode of MSDE is mixed mode.
The following article is for your reference:
INFO: MSDE Security and Authentication
http://support.microsoft.com/default...en-us;325022#3
2. Run the following command to test:
insert into tableA
SELECT a.*
FROM OPENROWSET('SQLOLEDB','<your MSDE instance name> ';'sa';'password',
'SELECT * FROM databaseA.dbo.tableB ') AS a
GO
Or
insert into tableA
select a.*
from
openrowset('sqloledb','Provider=sqloledb;UID=sa;PW D=password;Database=databa
seA;Server=<your MSDE instance name>', 'select * from [dbo].[tableB]') as a
Note:
1. You need to replace the <your MSDE instance name> with your MSDE
instance name.
For more detailed information about OPENROWSET, please refer to the
OPENROWSET topic in SQL Books Online(BOL).
I hope the information is helpful.
Sophie Guo
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
================================================== ===
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
================================================== ===
This posting is provided "AS IS" with no warranties, and confers no rights.
|||Hello Sophie,
Thank you! It works fine now
"Sophie Guo [MSFT]" <v-sguo@.online.microsoft.com> wrote in message
news:n2c8bveKFHA.2876@.TK2MSFTNGXA02.phx.gbl...
> Hello Eric,
> I have reproduced the issue on my side. Based on my research, the
> following
> command works well:
>
> insert into tableA
> SELECT a.*
> FROM OPENROWSET('SQLOLEDB','sophietest\msdeinstance';'s a';'password',
> 'SELECT * FROM test.dbo.tableB ') AS a
> GO
> or
> insert into tableA
> select a.*
> from
> openrowset('sqloledb','Provider=sqloledb;UID=sa;PW D=password;Database=test;S
> erver=sophietest\msdeinstance', 'select * from [dbo].[tableB]') as a
>
> Therefore, I recommend you perform the following commands:
> 1. Make sure the Authentication Mode of MSDE is mixed mode.
> The following article is for your reference:
> INFO: MSDE Security and Authentication
> http://support.microsoft.com/default...en-us;325022#3
>
> 2. Run the following command to test:
> insert into tableA
> SELECT a.*
> FROM OPENROWSET('SQLOLEDB','<your MSDE instance name> ';'sa';'password',
> 'SELECT * FROM databaseA.dbo.tableB ') AS a
> GO
>
> Or
>
> insert into tableA
> select a.*
> from
> openrowset('sqloledb','Provider=sqloledb;UID=sa;PW D=password;Database=databa
> seA;Server=<your MSDE instance name>', 'select * from [dbo].[tableB]') as
> a
>
> Note:
> 1. You need to replace the <your MSDE instance name> with your MSDE
> instance name.
>
> For more detailed information about OPENROWSET, please refer to the
> OPENROWSET topic in SQL Books Online(BOL).
>
> I hope the information is helpful.
> Sophie Guo
> Microsoft Online Partner Support
> Get Secure! - www.microsoft.com/security
> ================================================== ===
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ================================================== ===
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
>

OLE/DB provider returned message: Invalid authorization specification

Hello,
I'm trying to import a table from a MSDE database (databaseB) into a SQL
server database (database A).
Using to following sql statement:
insert tableA
select a.*
from openrowset(sqloledb,'Provider=sqloledb;P
assword=pwd;User ID=usr;Initial
Catalog=databaseA;Data Source=server', select * from [dbo].[tableB]'
) as a
I'm getting the following error:
[OLE/DB provider returned message: Invalid authorization specification]
[OLE/DB provider returned message: Invalid connection string attribute]
OLE DB error trace [OLE/DB Provider 'SQLOLEDB' IDBInitialize::Initialize
returned 0x80004005: ].
Everything runs fine if I use integrated security!? The used usr/pwd is a
MSDE login account.
A UDL file connection test directly to the MSDE database runs fine.
Thanx!
CHU! EricHello Eric,
I have reproduced the issue on my side. Based on my research, the following
command works well:
insert into tableA
SELECT a.*
FROM OPENROWSET('SQLOLEDB','sophietest\msdein
stance';'sa';'password',
'SELECT * FROM test.dbo.tableB ') AS a
GO
or
insert into tableA
select a.*
from
openrowset('sqloledb','Provider=sqloledb
;UID=sa;PWD=password;Database=test;S
erver=sophietest\msdeinstance', 'select * from [dbo].[tableB]') as a
Therefore, I recommend you perform the following commands:
1. Make sure the Authentication Mode of MSDE is mixed mode.
The following article is for your reference:
INFO: MSDE Security and Authentication
http://support.microsoft.com/defaul...;en-us;325022#3
2. Run the following command to test:
insert into tableA
SELECT a.*
FROM OPENROWSET('SQLOLEDB','<your MSDE instance name> ';'sa';'password',
'SELECT * FROM databaseA.dbo.tableB ') AS a
GO
Or
insert into tableA
select a.*
from
openrowset('sqloledb','Provider=sqloledb
;UID=sa;PWD=password;Database=databa
seA;Server=<your MSDE instance name>', 'select * from [dbo].[tableB]
') as a
Note:
1. You need to replace the <your MSDE instance name> with your MSDE
instance name.
For more detailed information about OPENROWSET, please refer to the
OPENROWSET topic in SQL Books Online(BOL).
I hope the information is helpful.
Sophie Guo
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
========================================
=============
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
========================================
=============
This posting is provided "AS IS" with no warranties, and confers no rights.|||Hello Sophie,
Thank you! It works fine now
"Sophie Guo [MSFT]" <v-sguo@.online.microsoft.com> wrote in message
news:n2c8bveKFHA.2876@.TK2MSFTNGXA02.phx.gbl...
> Hello Eric,
> I have reproduced the issue on my side. Based on my research, the
> following
> command works well:
>
> insert into tableA
> SELECT a.*
> FROM OPENROWSET('SQLOLEDB','sophietest\msdein
stance';'sa';'password',
> 'SELECT * FROM test.dbo.tableB ') AS a
> GO
> or
> insert into tableA
> select a.*
> from
> openrowset('sqloledb','Provider=sqloledb
;UID=sa;PWD=password;Database=test
;S
> erver=sophietest\msdeinstance', 'select * from [dbo].[tableB]') as
a
>
> Therefore, I recommend you perform the following commands:
> 1. Make sure the Authentication Mode of MSDE is mixed mode.
> The following article is for your reference:
> INFO: MSDE Security and Authentication
> http://support.microsoft.com/defaul...;en-us;325022#3
>
> 2. Run the following command to test:
> insert into tableA
> SELECT a.*
> FROM OPENROWSET('SQLOLEDB','<your MSDE instance name> ';'sa';'password',
> 'SELECT * FROM databaseA.dbo.tableB ') AS a
> GO
>
> Or
>
> insert into tableA
> select a.*
> from
> openrowset('sqloledb','Provider=sqloledb
;UID=sa;PWD=password;Database=data
ba
> seA;Server=<your MSDE instance name>', 'select * from [dbo].[table
B]') as
> a
>
> Note:
> 1. You need to replace the <your MSDE instance name> with your MSDE
> instance name.
>
> For more detailed information about OPENROWSET, please refer to the
> OPENROWSET topic in SQL Books Online(BOL).
>
> I hope the information is helpful.
> Sophie Guo
> Microsoft Online Partner Support
> Get Secure! - www.microsoft.com/security
> ========================================
=============
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ========================================
=============
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
>

OLE error code:80040E14

Hi,

I am getting the following error:

OLE error code:80040E14 in Microsoft OLE DB Provider for SQL Server
Column 'tags.id' is invalid in the select list because it is not
contained in either an aggregate function or the GROUP BY clause.

when trying to execute the following query:

select tags.id, name, count(*) as count from taggings, tags where
tags.id = tag_id group by tag_id

The above query works fine on MySQL, but chokes on SQL Server.

Could anyone please help?

Thanks!

NM(neutralm@.gmail.com) writes:

Quote:

Originally Posted by

I am getting the following error:
>
OLE error code:80040E14 in Microsoft OLE DB Provider for SQL Server
Column 'tags.id' is invalid in the select list because it is not
contained in either an aggregate function or the GROUP BY clause.
>
>
when trying to execute the following query:
>
select tags.id, name, count(*) as count from taggings, tags where
tags.id = tag_id group by tag_id
>
>
The above query works fine on MySQL, but chokes on SQL Server.


SQL Server, like most DB engines, as well as ANSI SQL, that if your
SELECT list includes an aggregate such as COUNT(*), and there is no
OVER clause for the aggregate, then all unaggregated columns in the
SELECT list must appear in the GROUP BY list.

Change tag_id in the GROUP BY clause to tags.id or vice versa.

Apparently MySQL is lax on this point. As a matter of fact SQL Server
4.x also permitted columns to appear in the SELECT list, if they did
not appear in GROUP BY. Sometimes the result made sense, as here
where tags.id is one-to-one with tags_id. Sometimes you got screenfulls
of garbage when you expected two lines, because you had left out a
column in the GROUP BY clause. The feature was removed in SQL Server
6.0 (and Sybase System 10), missed by few.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Thanks for your prompt reply, Erland. Pardon my ignorance, but I'm
still not sure if I understood how to solve the problem (although I
think I understand what the problem is from your explanation).

I have two tables:

1. tags (with the primary key 'id' and an attribute 'name')
2. taggings (the primary key is 'id', the foreign key is 'tag_id')

The query string I'm using is:

select tags.id, taggings.tag_id, name, count(*) as count from taggings,
tags where tags.id = taggings.tag_id group by taggings.tag_id

How should the correct query look like?

Thanks so much in advance!

Erland Sommarskog wrote:

Quote:

Originally Posted by

(neutralm@.gmail.com) writes:

Quote:

Originally Posted by

I am getting the following error:

OLE error code:80040E14 in Microsoft OLE DB Provider for SQL Server
Column 'tags.id' is invalid in the select list because it is not
contained in either an aggregate function or the GROUP BY clause.

when trying to execute the following query:

select tags.id, name, count(*) as count from taggings, tags where
tags.id = tag_id group by tag_id

The above query works fine on MySQL, but chokes on SQL Server.


>
SQL Server, like most DB engines, as well as ANSI SQL, that if your
SELECT list includes an aggregate such as COUNT(*), and there is no
OVER clause for the aggregate, then all unaggregated columns in the
SELECT list must appear in the GROUP BY list.
>
Change tag_id in the GROUP BY clause to tags.id or vice versa.
>
Apparently MySQL is lax on this point. As a matter of fact SQL Server
4.x also permitted columns to appear in the SELECT list, if they did
not appear in GROUP BY. Sometimes the result made sense, as here
where tags.id is one-to-one with tags_id. Sometimes you got screenfulls
of garbage when you expected two lines, because you had left out a
column in the GROUP BY clause. The feature was removed in SQL Server
6.0 (and Sybase System 10), missed by few.
>
--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
>
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx

|||neutralm@.gmail.com wrote:

Quote:

Originally Posted by

The query string I'm using is:
>
select tags.id, taggings.tag_id, name, count(*) as count from taggings,
tags where tags.id = taggings.tag_id group by taggings.tag_id
>
How should the correct query look like?


select taggings.tag_id, name, count(*) as tag_id_count
from taggins join tags on taggings.tag_id = tags.id
group by taggings.tag_id, name

Explanations:

1) GROUP BY must include all unaggregated columns from the SELECT,
i.e. everything that is not a COUNT(), SUM(), etc. (Why doesn't
it implicitly assume this? Apparently, it used to let you leave
things out, but that caused more trouble than it was worth. The
short answer is "just give it what it wants".)

2) tags.id and taggings.tag_id are forced to be equal, so you only need
to include one of them. Optional but recommended, as it's simpler
and conserves bandwidth.

3) The join is changed from SELECT ... FROM A, B WHERE A.X = B.Y
to SELECT ... FROM A JOIN B ON A.X = B.Y
Optional but recommended, as it keeps join conditions separate from
each other, and from other restrictions (e.g. NAME LIKE '%ABC%'),
all of which makes the query easier to understand.|||Thank you very much, Ed. I really appreciate how quickly you've help me
fix this problem!

Ed Murphy wrote:

Quote:

Originally Posted by

neutralm@.gmail.com wrote:
>

Quote:

Originally Posted by

The query string I'm using is:

select tags.id, taggings.tag_id, name, count(*) as count from taggings,
tags where tags.id = taggings.tag_id group by taggings.tag_id

How should the correct query look like?


>
select taggings.tag_id, name, count(*) as tag_id_count
from taggins join tags on taggings.tag_id = tags.id
group by taggings.tag_id, name
>
Explanations:
>
1) GROUP BY must include all unaggregated columns from the SELECT,
i.e. everything that is not a COUNT(), SUM(), etc. (Why doesn't
it implicitly assume this? Apparently, it used to let you leave
things out, but that caused more trouble than it was worth. The
short answer is "just give it what it wants".)
>
2) tags.id and taggings.tag_id are forced to be equal, so you only need
to include one of them. Optional but recommended, as it's simpler
and conserves bandwidth.
>
3) The join is changed from SELECT ... FROM A, B WHERE A.X = B.Y
to SELECT ... FROM A JOIN B ON A.X = B.Y
Optional but recommended, as it keeps join conditions separate from
each other, and from other restrictions (e.g. NAME LIKE '%ABC%'),
all of which makes the query easier to understand.