Showing posts with label query. Show all posts
Showing posts with label query. Show all posts

Thursday, March 29, 2012

error: Cursor not returned from query

I'm a really beginner about sql2000.
During my test I have created the following query. It's works ok until I
do't add the code included in section A, when I add it the i obtain the
error: Cursor not returned from query

Anyone can help me?

Thanks Carlo M.

set nocount on

IF OBJECT_ID('storico_big') IS NULL -- section A begin
create table storico_big( data datetime,
bcarrier varchar(20),
bda CHAR(30),
bzone char(50),
bdur int) ;
insert into storico_big -- section A
end

select top 10000
adetdate,bcarrier,bda,bzone,bdur
from pp_cdr (nolock)
where
adetdate < :data_fin and adetdate > :data_in order by adetdate
set nocount off

-- end of queryIW2FIV (carlo.merlini[NONROMPERE]@.libero.it) writes:
> I'm a really beginner about sql2000.
> During my test I have created the following query. It's works ok until I
> do't add the code included in section A, when I add it the i obtain the
> error: Cursor not returned from query

Apparently you are using some environment unknown to me. At least I
don't recognize the message.

> IF OBJECT_ID('storico_big') IS NULL -- section A begin
> create table storico_big( data datetime,
> bcarrier varchar(20),
> bda CHAR(30),
> bzone char(50),
> bdur int) ;
> insert into storico_big -- section A
> end

Since there are several apparent syntax errors here, it would have been nice
if you environment had returned the errors from SQL Server, rather than
bitching about the missing cursor.

It can be a good to run the query from Query Analyzer to get better
error diagnostics.

I don't really want to suggest a correction, because I can't understand
what you are trying to do. It appears that in the same batch that you first
want to create a table, insert into it, and then select data from another
table.

Possibly you want to insert the data from the SELECT statement into
storico_big, but in such case you should

1) get rid of that extraneous end
2) add an explicit column list to the INSERT statement.

However, I have a feeling that if you insert data into the table, the
client environment will still complain about a missing cursor...

--
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|||Erland Sommarskog wrote:
> IW2FIV (carlo.merlini[NONROMPERE]@.libero.it) writes:
> > I'm a really beginner about sql2000.
> > During my test I have created the following query. It's works ok until I
> > do't add the code included in section A, when I add it the i obtain the
> > error: Cursor not returned from query
> Apparently you are using some environment unknown to me. At least I
> don't recognize the message.
I would suspect that it's some data layer (such as ADO, ADO.NET, DAO,
etc), which has at least two different methods of performing work in
the database - one for performing data retrieval and another (possibly
on another object, if the layer is object oriented) which allows data
manipulation.

For instance, ADO.NET has ExecuteReader and ExecuteNonQuery methods on
it's command object.

Damien|||Damien (Damien_The_Unbeliever@.hotmail.com) writes:
> I would suspect that it's some data layer (such as ADO, ADO.NET, DAO,
> etc), which has at least two different methods of performing work in
> the database - one for performing data retrieval and another (possibly
> on another object, if the layer is object oriented) which allows data
> manipulation.
> For instance, ADO.NET has ExecuteReader and ExecuteNonQuery methods on
> it's command object.

Obviously IWZFIV is not using ADO .Net. ADO .Net does work with cursors
at all, as far as a I know. A more substantial clue is the condition:

adetdate < :data_fin and adetdate > :data_in order by adetdate

Apparently IWZFIV is using some form of embedded SQL.

Anyway, I would not really describe ADO .Net as providing different methods
for different purposes. If all you want is minimalism, you can do every-
thing with ExecuteReader. The other methods, ExecuteNonQuery, ExecuteScalar
and DataAdapter.Fill can be seen as convenience methods implemented on
top of ExecuteReader. (OK, this is not really true. There are some
fine differences when there are multiple error messages and result sets
interleaved.)
--
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

Error: Contains more than the maximum number of prefixes. The max

I am running an update statement in query analyzer to update a database with
data from another database on another server.
I am running into the error : Error: Contains more than the maximum number
of prefixes. Maximum is 3
How do I overcome this error. I am the admin on both servers.http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=44062
DishanF
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!|||I was trying to do something similar by doing an update and "pushing" the da
ta across to a linked server with the following:
update ServerName.AAD.dbo.t_employee
set ServerName.AAD.dbo.t_employee.work_shift = wa.work_shift
from t_employee wa
where ServerName.AAD.dbo.t_employee.id = wa.id
and wa.id = '105'
I was also getting the following:
Server: Msg 117, Level 15, State 2, Line 4
The number name 'ServerName.AAD.dbo.t_employee' contains more than the maxim
um number of prefixes. The maximum is 3.
It's a simple, but not obvious, answer. Put the table you are updating in th
e FROM clause with an alias and update the alias, as follows:
update la
set la.work_shift = wa.work_shift
from ServerName.AAD.dbo.t_employee la, t_employee wa
where la.id = wa.id
and wa.id = '105'
You have to love simple answers. Finding them is the challenging part. :)sql

Error: Contains more than the maximum number of prefixes. Maximum

I am running an update statement in query analyzer to update a database with
data from another database on another server.
I am running into the error : Error: Contains more than the maximum number
of prefixes. Maximum is 3
How do I overcome this error. I am the admin on both servers.
> I am running an update statement in query analyzer to update a database
with
> data from another database on another server.
> I am running into the error : Error: Contains more than the maximum number
> of prefixes. Maximum is 3
> How do I overcome this error. I am the admin on both servers.
Object names in SQL Server have 4 parts: server.database.owner.objectname
Therefore, you ca have only 3 prefixes. Check the names in your Update
query.
Dejan Sarka, SQL Server MVP
Associate Mentor
www.SolidQualityLearning.com

Monday, March 26, 2012

Error: 8624 Internal Query Processor Error: The query processor could not produce a query plan.

SQL Server 2005 9.0.3161 on Win 2k3 R2

I receive the following error:

"Error: 8624, Severity: 16, State: 1 Internal Query Processor Error: The query processor could not produce a query plan. For more information, contact Customer Support Services."

I have traced this to an insert statement that executes as part of a stored procedure.

INSERT INTO ledger (journal__id, account__id,account_recv_info__id,amount)

VALUES (@.journal_id, @.acct_id, @.acct_recv_id, @.amount)

There is also an auto-increment column called id. There are FK contraints on all of the columns ending in "__id". I have found that if I remove the contraint on account__id the procedure will execute without error. None of the other constraints seem to make a difference. Of course I don't want to remove this key because it is important to the database integrity and should not be causing problems, but apparently it confuses the optimizer.

Also, the strange thing is that I can get the procedure to execute without error when I run it directly through management studio, but I receive the error when executing from .NET code or anything using ODBC (Access).

I'd suggest calling PSS. It does sound like a bug here.

|||

I ran into this exact problem today, and it turned out to be related to a catalog being inconsistent, when we performed a migration from a SQL 2000 server to a SQL 2005 server, by restoring a backup . There was a foreign key constraint that was not functioning correctly following the migration and that was causing the error to show up.

We had restored the SQL 2000 backup to a 2005 server, then changed the compatability mode from 80 to 90, then updated statistics. We did not however, run the DBCC following all of that. We had run tests prior to the migration, but this hadn't showed up as an issue until the day of the migration. As a matter of fact, we had run DBCC's on the SQL 2000 database and things were fine. We checked the backup file, and that was fine. The problem was in some part of the page migrations that happen within the engine itself. Maybe this was a page alignment issue, whereby a given catalog page was in a decent state for migration when we were testing, but changed it's alignment on a given page between the time we tested and the time that we migrated. Who know....that's just my speculation.

The error from running a simple insert statement looks like this:

Msg 8624, Level 16, State 1, Line 1

Internal Query Processor Error: The query processor could not produce a query plan. For more information, contact Customer Support Services.

The error from the DBCC CHECKDB looks like this:

Msg 8992, Level 16, State 1, Line 1

Check Catalog Msg 3853, State 1: Attribute (referenced_object_id=238623893,key_index_id=3) of row (object_id=951674438) in sys.foreign_keys does not have a matching row (object_id=238623893,index_id=3) in sys.indexes.

CHECKDB found 0 allocation errors and 1 consistency errors not associated with any single object.

This lead us to the conclusion that we could drop the FK and recreate it, and have everything work. And, it did.

The moral of the story, like it's been said many times...run DBCC's after restores when going from SQL 2000 to SQL 2005.

Hope this helps someone else in the future.

-- Don

|||

I consulted tech support. It was finally classified as a bug. The database was in 80 compatibility and changing it to 90 made the problem go away. The other work around was to set arithabort on. This explained why it worked from management studio and not anywhere else. Apparently management studio has arithabort set to on by default. The following is the case closure confirmation from the MS engineer:

PROBLEM:

=======

An insert query to a table that has foreign key references cannot generate a plan with error 8624 when arithabort is set to be off.

Server: Msg 8624, Level 16, State 1, Line 1 Internal Query Processor Error: The query processor could not produce a query plan. For more information, contact Customer Support Services.

AGREED UPON CRITERIA FOR RESOLUTION:

===========================

Investigate root cause

CAUSE:

=====

This issue appears to be related to the fact database compatibility is set to 80.I have filed a product bug for tracking purpose

RESOLUTION:

===========

Setting database compatibility to be 90 resolved the issue

Error: 8624 Internal Query Processor Error: The query processor could not produce a query plan.

SQL Server 2005 9.0.3161 on Win 2k3 R2

I receive the following error:

"Error: 8624, Severity: 16, State: 1 Internal Query Processor Error: The query processor could not produce a query plan. For more information, contact Customer Support Services."

I have traced this to an insert statement that executes as part of a stored procedure.

INSERTINTO ledger (journal__id, account__id,account_recv_info__id,amount)

VALUES(@.journal_id, @.acct_id, @.acct_recv_id, @.amount)

There is also an auto-increment column called id. There are FK contraints on all of the columns ending in "__id". I have found that if I remove the contraint on account__id the procedure will execute without error. None of the other constraints seem to make a difference. Of course I don't want to remove this key because it is important to the database integrity and should not be causing problems, but apparently it confuses the optimizer.

Also, the strange thing is that I can get the procedure to execute without error when I run it directly through management studio, but I receive the error when executing from .NET code or anything using ODBC (Access).

I'd suggest calling PSS. It does sound like a bug here.

|||

I ran into this exact problem today, and it turned out to be related to a catalog being inconsistent, when we performed a migration from a SQL 2000 server to a SQL 2005 server, by restoring a backup . There was a foreign key constraint that was not functioning correctly following the migration and that was causing the error to show up.

We had restored the SQL 2000 backup to a 2005 server, then changed the compatability mode from 80 to 90, then updated statistics. We did not however, run the DBCC following all of that. We had run tests prior to the migration, but this hadn't showed up as an issue until the day of the migration. As a matter of fact, we had run DBCC's on the SQL 2000 database and things were fine. We checked the backup file, and that was fine. The problem was in some part of the page migrations that happen within the engine itself. Maybe this was a page alignment issue, whereby a given catalog page was in a decent state for migration when we were testing, but changed it's alignment on a given page between the time we tested and the time that we migrated. Who know....that's just my speculation.

The error from running a simple insert statement looks like this:

Msg 8624, Level 16, State 1, Line 1

Internal Query Processor Error: The query processor could not produce a query plan. For more information, contact Customer Support Services.

The error from the DBCC CHECKDB looks like this:

Msg 8992, Level 16, State 1, Line 1

Check Catalog Msg 3853, State 1: Attribute (referenced_object_id=238623893,key_index_id=3) of row (object_id=951674438) in sys.foreign_keys does not have a matching row (object_id=238623893,index_id=3) in sys.indexes.

CHECKDB found 0 allocation errors and 1 consistency errors not associated with any single object.

This lead us to the conclusion that we could drop the FK and recreate it, and have everything work. And, it did.

The moral of the story, like it's been said many times...run DBCC's after restores when going from SQL 2000 to SQL 2005.

Hope this helps someone else in the future.

-- Don

|||

I consulted tech support. It was finally classified as a bug. The database was in 80 compatibility and changing it to 90 made the problem go away. The other work around was to set arithabort on. This explained why it worked from management studio and not anywhere else. Apparently management studio has arithabort set to on by default. The following is the case closure confirmation from the MS engineer:

PROBLEM:

=======

An insert query to a table that has foreign key references cannot generate a plan with error 8624 when arithabort is set to be off.

Server: Msg 8624, Level 16, State 1, Line 1 Internal Query Processor Error: The query processor could not produce a query plan. For more information, contact Customer Support Services.

AGREED UPON CRITERIA FOR RESOLUTION:

===========================

Investigate root cause

CAUSE:

=====

This issue appears to be related to the fact database compatibility is set to 80.I have filed a product bug for tracking purpose

RESOLUTION:

===========

Setting database compatibility to be 90 resolved the issue

Sunday, March 11, 2012

Error: 1203

Query:
update entries
set item_convert_status=0,
item_code=key_cross_ref.item_code,
mida=key_cross_ref.mida,
zeva_default=key_cross_ref.zeva_default
from entries,key_cross_ref
where entries.company_code=1
and (ltrim(rtrim(entries.origin_barcode))=key_cross_ref.barcode or
entries.origin_item_code=key_cross_ref.barcode)
Somtimes i get 2 error logs:
--Error: 1203, Severity: 20, State: 1
--Process ID 53 attempting to unlock unowned resource PAG: 30:1:136319..
Someone?I found this article http://support.microsoft.com/?kbid=814654
--
--
Jack Vamvas
___________________________________
Receive free SQL tips - www.ciquery.com/sqlserver.htm
___________________________________
"msforums.mircosoft.com" <chen_sh@.hotmail.com> wrote in message
news:ePdozacbGHA.2456@.TK2MSFTNGP04.phx.gbl...
> Query:
> update entries
> set item_convert_status=0,
> item_code=key_cross_ref.item_code,
> mida=key_cross_ref.mida,
> zeva_default=key_cross_ref.zeva_default
> from entries,key_cross_ref
> where entries.company_code=1
> and (ltrim(rtrim(entries.origin_barcode))=key_cross_ref.barcode or
> entries.origin_item_code=key_cross_ref.barcode)
> Somtimes i get 2 error logs:
> --Error: 1203, Severity: 20, State: 1
> --Process ID 53 attempting to unlock unowned resource PAG: 30:1:136319..
> Someone?
>

Error: [DBNETLIB]ConnectionCheckForData

I have gotten an error, which appears to be a query optimizer bug:
[Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionCheckForData
(CheckforData()).
Server: Msg 11, Level 16, State 1, Line 0
General network error. Check your network documentation.
Connection Broken
I admit that the query is a bit complex -- it joins three tables and uses a
view -- but it is perfect okay. If I make minor, irrelevant, changes to the
syntax it works. For example, the failing query contains WHERE TBL_D.sold_to
= 60414; if I change this to WHERE TBL_D.sold_to BETWEEN 60414 and 60414 then
the query works. It returns in a few seconds with 5 rows. Also, if I change
the query to say INNER LOOP JOIN instead of INNER JOIN then it will work
correctly.
Running dbcc checktable on the tables shows no error.
The query is generated by a Report Generator, so I cannot just make manual
changes to it; the only thing I can do is to find out the underlying cause. I
am running SQL Server 2000 version 8.00.760 (Intel X86) (Build 2195: Service
Pack 4).
Has anyone seen this kind of error, or aware of any patch that will fix it?Tycus,
This sounds like a problem in your networking hardware or configuration
somewhere. Look at your network interface settings - especially duplex
settings. Sometimes setting the NICs to Auto duples causes these errors
(sometimes they don't).
Is there anything further in the SQL Server error log? Stack dumps? Once
you've checked your networking components, and you still get the error, raise
a call with Microsoft Product Support.
--
Mark Allison, SQL Server MVP
http://www.markallison.co.uk
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602m.html
"Tycus" wrote:
> I have gotten an error, which appears to be a query optimizer bug:
> [Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionCheckForData
> (CheckforData()).
> Server: Msg 11, Level 16, State 1, Line 0
> General network error. Check your network documentation.
> Connection Broken
> I admit that the query is a bit complex -- it joins three tables and uses a
> view -- but it is perfect okay. If I make minor, irrelevant, changes to the
> syntax it works. For example, the failing query contains WHERE TBL_D.sold_to
> = 60414; if I change this to WHERE TBL_D.sold_to BETWEEN 60414 and 60414 then
> the query works. It returns in a few seconds with 5 rows. Also, if I change
> the query to say INNER LOOP JOIN instead of INNER JOIN then it will work
> correctly.
> Running dbcc checktable on the tables shows no error.
> The query is generated by a Report Generator, so I cannot just make manual
> changes to it; the only thing I can do is to find out the underlying cause. I
> am running SQL Server 2000 version 8.00.760 (Intel X86) (Build 2195: Service
> Pack 4).
> Has anyone seen this kind of error, or aware of any patch that will fix it?

Error: [DBNETLIB]ConnectionCheckForData

I have gotten an error, which appears to be a query optimizer bug:
[Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionCheckForD
ata
(CheckforData()).
Server: Msg 11, Level 16, State 1, Line 0
General network error. Check your network documentation.
Connection Broken
I admit that the query is a bit complex -- it joins three tables and uses a
view -- but it is perfect okay. If I make minor, irrelevant, changes to the
syntax it works. For example, the failing query contains WHERE TBL_D.sold_to
= 60414; if I change this to WHERE TBL_D.sold_to BETWEEN 60414 and 60414 the
n
the query works. It returns in a few seconds with 5 rows. Also, if I change
the query to say INNER LOOP JOIN instead of INNER JOIN then it will work
correctly.
Running dbcc checktable on the tables shows no error.
The query is generated by a Report Generator, so I cannot just make manual
changes to it; the only thing I can do is to find out the underlying cause.
I
am running SQL Server 2000 version 8.00.760 (Intel X86) (Build 2195: Servic
e
Pack 4).
Has anyone seen this kind of error, or aware of any patch that will fix it?Tycus,
This sounds like a problem in your networking hardware or configuration
somewhere. Look at your network interface settings - especially duplex
settings. Sometimes setting the NICs to Auto duples causes these errors
(sometimes they don't).
Is there anything further in the SQL Server error log? Stack dumps? Once
you've checked your networking components, and you still get the error, rais
e
a call with Microsoft Product Support.
Mark Allison, SQL Server MVP
http://www.markallison.co.uk
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602m.html
"Tycus" wrote:
[vbcol=seagreen]
> I have gotten an error, which appears to be a query optimizer bug:
> [Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionCheckFo
rData
> (CheckforData()).
> Server: Msg 11, Level 16, State 1, Line 0
> General network error. Check your network documentation.
> Connection Broken
> I admit that the query is a bit complex -- it joins three tables and uses
a
> view -- but it is perfect okay. If I make minor, irrelevant, changes to th
e
> syntax it works. For example, the failing query contains WHERE TBL_D.sold_
to
> = 60414; if I change this to WHERE TBL_D.sold_to BETWEEN 60414 and 60414 t
hen
> the query works. It returns in a few seconds with 5 rows. Also, if I chang
e
> the query to say INNER LOOP JOIN instead of INNER JOIN then it will work
> correctly.
> Running dbcc checktable on the tables shows no error.
> The query is generated by a Report Generator, so I cannot just make manual
> changes to it; the only thing I can do is to find out the underlying cause
. I
> am running SQL Server 2000 version 8.00.760 (Intel X86) (Build 2195: Serv
ice
> Pack 4).
> Has anyone seen this kind of error, or aware of any patch that will fix it?[/vbcol
]

Error: [DBNETLIB]ConnectionCheckForData

I have gotten an error, which appears to be a query optimizer bug:
[Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionCheckForData
(CheckforData()).
Server: Msg 11, Level 16, State 1, Line 0
General network error. Check your network documentation.
Connection Broken
I admit that the query is a bit complex -- it joins three tables and uses a
view -- but it is perfect okay. If I make minor, irrelevant, changes to the
syntax it works. For example, the failing query contains WHERE TBL_D.sold_to
= 60414; if I change this to WHERE TBL_D.sold_to BETWEEN 60414 and 60414 then
the query works. It returns in a few seconds with 5 rows. Also, if I change
the query to say INNER LOOP JOIN instead of INNER JOIN then it will work
correctly.
Running dbcc checktable on the tables shows no error.
The query is generated by a Report Generator, so I cannot just make manual
changes to it; the only thing I can do is to find out the underlying cause. I
am running SQL Server 2000 version 8.00.760 (Intel X86) (Build 2195: Service
Pack 4).
Has anyone seen this kind of error, or aware of any patch that will fix it?
Tycus,
This sounds like a problem in your networking hardware or configuration
somewhere. Look at your network interface settings - especially duplex
settings. Sometimes setting the NICs to Auto duples causes these errors
(sometimes they don't).
Is there anything further in the SQL Server error log? Stack dumps? Once
you've checked your networking components, and you still get the error, raise
a call with Microsoft Product Support.
Mark Allison, SQL Server MVP
http://www.markallison.co.uk
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602m.html
"Tycus" wrote:

> I have gotten an error, which appears to be a query optimizer bug:
> [Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionCheckForData
> (CheckforData()).
> Server: Msg 11, Level 16, State 1, Line 0
> General network error. Check your network documentation.
> Connection Broken
> I admit that the query is a bit complex -- it joins three tables and uses a
> view -- but it is perfect okay. If I make minor, irrelevant, changes to the
> syntax it works. For example, the failing query contains WHERE TBL_D.sold_to
> = 60414; if I change this to WHERE TBL_D.sold_to BETWEEN 60414 and 60414 then
> the query works. It returns in a few seconds with 5 rows. Also, if I change
> the query to say INNER LOOP JOIN instead of INNER JOIN then it will work
> correctly.
> Running dbcc checktable on the tables shows no error.
> The query is generated by a Report Generator, so I cannot just make manual
> changes to it; the only thing I can do is to find out the underlying cause. I
> am running SQL Server 2000 version 8.00.760 (Intel X86) (Build 2195: Service
> Pack 4).
> Has anyone seen this kind of error, or aware of any patch that will fix it?

Friday, March 9, 2012

error with subquery.....

I am getting an error from a query that that has a subquery.

Msg 512, Level 16, State 1, Line 2

Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

(0 row(s) affected)

This is a the query.

select *

from dhcp

where nameofcomputer = (SELECT p.nameofcomputer

FROM v_Pams_DHCP p

Left Outer Join adat2005_main a

ON p.nameofcomputer = a.nameofcomputer

where a.serialnumber is null)

Thanks in advance.

Gene

Use in operator,

Code Snippet

select

*

from

dhcp

where

nameofcomputer

in (

SELECT

p.nameofcomputer

FROM

v_Pams_DHCP p

Left Outer Join adat2005_main a

ON p.nameofcomputer = a.nameofcomputer

where

a.serialnumber is null

)

Exists Might be faster than IN,

Code Snippet

select

*

from

dhcp

where

Exists

(

SELECT

p.nameofcomputer

FROM

v_Pams_DHCP p

Left Outer Join adat2005_main a

ON p.nameofcomputer = a.nameofcomputer

where

a.serialnumber is null and p.nameofcomputer = dhcp.nameofcomputer

)

Wednesday, March 7, 2012

Error with opening the connection

I have created my query to do what it needs to do but i'm getting error when i click the button, it says there is an error opening my connectiong...

I.E.

Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:System.Data.SqlClient.SqlException: Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.

Source Error:

Line 28: Line 29: //open the connectionLine 30: myConnection.Open();Line 31: Line 32: //create a command


Source File:c:\Documents and Settings\plan\PlanDatabase\BZAvuAdd.aspx.cs Line:30

Stack Trace:

[SqlException (0x80131904): Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.] System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +171 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +199 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2305 System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +34 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +606 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +193 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +502 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +28 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +429 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +70 System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +512 System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +85 System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +89 System.Data.SqlClient.SqlConnection.Open() +160 _Default.insertIntoVU() in c:\Documents and Settings\plan\PlanDatabase\BZAvuAdd.aspx.cs:30 _Default.addAppButton_Click(Object sender, EventArgs e) in c:\Documents and Settings\plan\PlanDatabase\BZAvuAdd.aspx.cs:127 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +75 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +98 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4919

therefor is this saying that I have to login before even testing this thing or what??

Can you post the rest of your connection code?

|||

yeah...if you want html let meknow

here is the c#

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Data.SqlClient;

publicpartialclass_Default : System.Web.UI.Page

{

protectedvoid Page_Load(object sender,EventArgs e)

{

String parcel = (String)Session["parcelNumber"];

parcelNumLabel.Text = parcel;

}

protectedvoid insertApplicant()

{

//create the connection object

SqlConnection myConnection =newSqlConnection();

//set the connection string

myConnection.ConnectionString =ConfigurationManager.ConnectionStrings["MRDDstringConnection"].ConnectionString;

//open the connection

myConnection.Open();

//create a command

SqlCommand myCommand =newSqlCommand();//for data entry into applicant table

//***set the query text to the name of a stored procedure

myCommand.CommandText ="SELECT FirstName, LastName, Line1, Line2, City, State, Zip, PhoneNum FROM Applicant WHERE FirstName = @.fname, LastName = @.lname, Line1 = @.line1, Line2 = @.line2, City = @.city, State = @.state, Zip = @.zip, PhoneNum = @.phone";

/*

//***set the command type, stored procedure

myCommand.CommandType = CommandType.StoredProcedure;

*/

//create an input parameter

SqlParameter firstName =newSqlParameter();

firstName.ParameterName ="@.firstName";

firstName.SqlDbType =SqlDbType.Char;

firstName.Size = 10;

firstName.Value = ApplicantFirst.Text;//set the first name from text box

//create an input parameter

SqlParameter lastName =newSqlParameter();

lastName.ParameterName ="@.lastName";

lastName.SqlDbType =SqlDbType.Char;

lastName.Size = 20;

lastName.Value = ApplicantLast.Text;//set the last name from text box

//create an input parameter

SqlParameter line1 =newSqlParameter();

line1.ParameterName ="@.line1";

line1.SqlDbType =SqlDbType.Char;

line1.Size = 75;

line1.Value = ApplicantLine1.Text;//set the 1 line of address from text box

//create an input parameter

SqlParameter line2 =newSqlParameter();

line2.ParameterName ="@.line2";

line2.SqlDbType =SqlDbType.Char;

line2.Size = 75;

line2.Value = ApplicantLine2.Text;//set the 2 line of address from text box

//create an input parameter

SqlParameter city =newSqlParameter();

city.ParameterName ="@.city";

city.SqlDbType =SqlDbType.Char;

city.Size = 25;

city.Value = ApplicantCity.Text;//set the city from text box

//create an input parameter

SqlParameter state =newSqlParameter();

state.ParameterName ="@.state";

state.SqlDbType =SqlDbType.Char;

state.Size = 2;

state.Value = ApplicantState.SelectedItem;//set the state from text box

//create an input parameter

SqlParameter zip =newSqlParameter();

zip.ParameterName ="@.zip";

zip.SqlDbType =SqlDbType.BigInt;

zip.Size = 8;

zip.Value = ApplicantZip.SelectedItem;//set the zip code from text box

//create an input parameter

SqlParameter phone =newSqlParameter();

phone.ParameterName ="@.phone";

phone.SqlDbType =SqlDbType.Char;

phone.Size = 14;

phone.Value = ApplicantPhone.Text;//set the phone number from text box

//add the parameters

myCommand.Parameters.Add(firstName);//inserts first name into table

myCommand.Parameters.Add(lastName);//inserts last name into table

myCommand.Parameters.Add(line1);//inserts line1 of address into table

myCommand.Parameters.Add(line2);//inserts line2 of address into table

myCommand.Parameters.Add(city);//inserts city into table

myCommand.Parameters.Add(state);//inserts state into table

myCommand.Parameters.Add(zip);//inserts zip code into table

myCommand.Parameters.Add(phone);//inserts ohone number into table

//associate a connection with a command

myCommand.Connection = myConnection;

//execute the query

myCommand.ExecuteNonQuery();

//give back all resources

myCommand.Dispose();

myConnection.Dispose();

testlabel.Text ="Successful";

}

protectedvoid insertVofU()

{

//create the connection object

SqlConnection myConnection =newSqlConnection();

//set the connection string

myConnection.ConnectionString =ConfigurationManager.ConnectionStrings["MRDDstringConnection"].ConnectionString;

//open the connection

myConnection.Open();

//create a command

SqlCommand myCommand =newSqlCommand();//for data entry into Variance of use Table

//***set the query text to the name of a stored procedure

myCommand.CommandText ="SELECT BZAcaseNum, CurrentUse, ProposedUse, Comments FROM VarianceOfUse WHERE BZAcaseNum = @.caseNum, CurrentUse = @.current, ProposedUse = @.proposedUse, Comments = @.comments";/*

//***set the command type, stored procedure

myCommand.CommandType = CommandType.StoredProcedure;

*/

/*>>>>>

>>>>>>> //create an input parameter

>>>>>>> SqlParameter caseNum = new SqlParameter();

CaseNum caseNum.ParameterName = "@.caseNum";

>>>>>>> caseNum.SqlDbType = SqlDbType.Char;

>>>>>>> caseNum.Size = 10;

>>>>>>> caseNum.Value = ApplicantFirst.Text; //set the BZA Case Number Automatically

>>>>>>> */

//create an input parameter

SqlParameter current =newSqlParameter();

current.ParameterName ="@.current";

current.SqlDbType =SqlDbType.Char;

current.Size = 100;

current.Value = currentUse.Text;//set the current use from text box

//create an input parameter

SqlParameter proposedUse =newSqlParameter();

proposedUse.ParameterName ="@.proposedUse";

proposedUse.SqlDbType =SqlDbType.Char;

proposedUse.Size = 500;

proposedUse.Value = proposedUseText.Text;//set the proposed use from text box

//create an input parameter

SqlParameter comments =newSqlParameter();

comments.ParameterName ="@.comments";

comments.SqlDbType =SqlDbType.Char;

comments.Size = 500;

comments.Value = whyText.Text;//set the comments from text box

//add the parameters

//>>>>> myCommand.Parameters.Add(caseNum); //inherits BZA Case Number

myCommand.Parameters.Add(current);//inserts currentUse into table

myCommand.Parameters.Add(proposedUse);//inserts proposedUse into table

myCommand.Parameters.Add(comments);//inserts comments into table

//associate a connection with a command

myCommand.Connection = myConnection;

//execute the query

myCommand.ExecuteNonQuery();

//give back all resources

myCommand.Dispose();

myConnection.Dispose();

testlabel.Text ="Successful2";

}

protectedvoid addAppButton_Click(object sender,EventArgs e)

{

insertApplicant();

insertVofU();

}

|||

First, put some debug code in that checks your connection string:

ConfigurationManager.ConnectionStrings["MRDDstringConnection"].ConnectionString;

If this is null (meaning the connection string does not exist for your current application), this is something you will need to fix. Also, make sure it has a username/password.

The third thing to check is how you are logging in. If this is a SQL Server, you may have Mixed Mode Authentication turned off for the database. You might be able to log in fine using Windows Authentication Mode, but remote applications will not be able to access the database until Mixed Mode Authentication is turned on.

You can read more about it here:

http://support.microsoft.com/kb/889615

Hope this helps.

|||<addname ="MRDDstringConnection"connectionString="server = khazad-dum; database = mrdd3;"providerName="System.data.SqlClient"/>

</connectionStrings>

that is the HTML i used for creating the connection string is something wrong in there?

|||

i found the problem in my html.....didn't work at all so thanks for all the help you got me started in the right direction

|||

Text should be:

<connectionStrings> <addname="MRDDstringConnection"connectionString="Data Source=khazad-dum;Initial Catalog=mrdd3;Persist Security Info=True;User ID=<username here>;Password=<password here>"providerName="System.Data.SqlClient" />

</connectionStrings>

Once you have this in your web.config file, you'll need to make sure you have Mixed Mode Authentication turned on. In SQL Server 2005, you can do this by right-clicking the server, go to Properties, select Security, and make sure "SQL Server and Windows Authentication Mode" is selected.

** PLEASE NOTE: You will have to put a username and password in the connection string above.

|||

i put in the username and password and it doesn't work it says i can't login...i know the username and password are correct...where is it checking for the user name and password cause my administrators are idiots...and they don't know what they are doing so i'm trying to figure out this part....

|||

Check to make sure Mixed Mode Authentication is turned on. What are you using for a back-end? SQL Server 2005?

|||

yes...the back end is SQL server 2005, and mixed-mode is turned on...and i created my username in the enterprise manage and set the permissions to the owner of the db....withouth the username and password i had it successfully going through with no errors, but it wasn't writting so now once the database knows its my user name i will be able to write to it...i'm lost at this point

|||

Are IIS, the .NET Framework and the SQL Server all running on the same machine? If so, make sure you are using a login that exists on the SQL Server (open SQL Server Management Studio and look under Security -> Logins).

The only reason you should get a Login failed for user '(null)' is:
1) there was no login ID supplied
2) the login ID supplied does not exist as a SQL Server login
3) mixed mode authentication is off

If mixed mode authentication is on, and you are supplying a login ID, we should start looking at the existing logins under SQL Server.

|||

ok, when i go look in the Enterprise manager the login name I'm currently under (MIRKWOOD\plan) that is the login name that shows up on the logins page, now i don't have to include MIRKWOOD in the html portion becuase of the fact that MIRKWOOD is the server name...but i tried just regular (plan) i tried (MIRKWOOD\plan), i tried it with the password i use, and without the password i use...none of them work...i have no clue...and the mixed mode authentication is on....also in the security tab it says "Audit Level" - "None" checked, "Ownership Chairing" - not checked, "Start and Run SQL server in the following account" - its a totally different user name and password i've seen....is that where the problem is?? maybe this will help you...sorry for being a hassel...i've just never delt with this before

|||

Put this in your web.config file (replace your old connection string):

<addname="MRDDstringConnection"connectionString="Data Source=<servername here>;Initial Catalog=<database name here>;Persist Security Info=True;User ID=<username here>;Password=<password here>"providerName="System.Data.SqlClient" />

You will have to change the Uesr ID and Password to a login you know exists.

I have to admit I am a bit confused. Earlier, it looked like you were trying to connect to a server named "khazad-dum" (neat Babylon 5 reference, by the wayCool) and a database named "mrdd3", but now it appears you are trying to connect to a server named "MIRKWOOD" and a database named "plan".

The User ID and Password would be the login as it exists in SQL Management Studio.

|||

I am trying to connect to a server name Khazad-Dum...that is where SQL server is located and my database...but my user name and password come from this other server name mirkwood....when i look in the security tab and then logins there is one under there called "MIRKWOOD\plan" now i'm almost 100% positive that is my login name but when i put it in my code it says that the name does not exist..really wierd...and my admin has no clue how he names stuff so i'm stuck here trying to figure this out...ughhh...if you have anymore suggestions that would be great...thanks for the help you have provided so far i understand everything you are saying and how it goes...i'm assuming it is the naming sequence...

|||

I am trying to connect to a server name Khazad-Dum...that is where SQL server is located and my database...but my user name and password come from this other server name mirkwood....when i look in the security tab and then logins there is one under there called "MIRKWOOD\plan" now i'm almost 100% positive that is my login name but when i put it in my code it says that the name does not exist..really wierd...and my admin has no clue how he names stuff so i'm stuck here trying to figure this out...ughhh...if you have anymore suggestions that would be great...thanks for the help you have provided so far i understand everything you are saying and how it goes...i'm assuming it is the naming sequence...in fact here is the html i'm using now...and still getting the error...

<addname="MRDDstringConnection"connectionString="Data Source=KHAZAD-DUM;Initial Catalog=mrdd3;Persist Security Info=True;User ID = \mirkwood\plan; Password=********"

providerName="System.Data.SqlClient" />

Sunday, February 26, 2012

Error with linked server after failover

Hi all,

The following query that uses a linked server is giving me the error message below after I initiate a failover (ALTER DATABASE Northwind SET PARTNER FAILOVER).I have SQL Server 2005 SP2.I think that without the service pack there is another error too.

The query is run from a database other than northwind of course.

select * from DualLink.northwind.dbo.Test1

Please note that:

without a failover itworks perfectly

it always work if I try to run it a second time - only the first time it fails.

it fails the first time for each of the open connections. A new connection that was open after the failover will work fine.

A transport-level error has occurred when sending the request to the server. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)

A transport-level error has occurred when sending the request to the server. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.)

The linked server is defined as

EXEC master.

dbo.sp_addlinkedserver

@.server = N'DualLink',

@.srvproduct=N'',

@.provider=N'SQLOLEDB',

@.catalog=N'northwind',

@.provstr=N'Server=(local);FailoverPartner=MyIPAddr;'

EXEC master.dbo.sp_addlinkedsrvlogin

@.rmtsrvname = 'DualLink',

@.useself = false,

@.locallogin = 'sa',

@.rmtuser = 'sa',

@.rmtpassword = 'MyPwd'

Thanks,

Avi

I am having the same problem except I don't have a linked server.

I am running SQL Server 2005 sp1 and Windows 2003 using clustering.

In addition to your symptoms I have noticed the following:

1. The error occurs when I make a query through Server Manager and when using a java app that queries a database using an ASP page. However, if I bring up our website as the first request after failover it works fine.

2. If I failover from Server1 to Server2 and don't make any requests while it is on Server2 and then failover back to Server1 I do not get the error. If I make any requests while it is on Server2 then the first request I make on Server1 after failing over will cause the error.

If you have solved the problem I would like to know how. If I find a solution I will post it here.

Blake

error with linked server

Hi
when i try to run a query using linked servers, i get the following
error.

Server: Msg 125, Level 15, State 1, Line 1
Case expressions may only be nested to level 10.

I do have more than 10 case statements, it works fine when it is less
than 10. can anyone tell me if there is a way to have more than 10
case statements. thanks alot.

Jay

my query
Select category, val, Sum(QTY) As QTY , yr
From
(
Select val, QTY2 As QTY,
KEEP = Case
When code = '004' And ((YR > 2003) Or (YR = 2003 And MON > 12))
Then 'N'
When CODE = '005' And ((YR > 2003) Or (YR = 2003 And MON > 12))
Then 'N'
When CODE = '003' And ((YR > 2003) Or (YR = 2003 And MON > 12))
Then 'N'
When CODE = '017' And ((YR > 2003) Or (YR = 2003 And MON > 12))
Then 'N'
When CODE = '007' And ((YR > 2003) Or (YR = 2003 And MON > 12))
Then 'N'
When CODE = '008' And ((YR > 2003) Or (YR = 2003 And MON > 12))
Then 'N'
When CODE = '009' And ((YR > 2003) Or (YR = 2003 And MON > 11))
Then 'N'
When CODE = '010' And ((YR > 2003) Or (YR = 2003 And MON > 12))
Then 'N'
When CODE = '038' And ((YR > 2003) Or (YR = 2003 And MON > 12))
Then 'N'
When CODE = '032' And ((YR > 2003) Or (YR = 2003 And MON > 12))
Then 'N'
When CODE = '030' And ((YR > 2003) Or (YR = 2003 And MON > 12))
Then 'N'
When CODE = '018' And ((YR > 2003) Or (YR = 2003 And MON > 12))
Then 'N'
Else 'Y' End
From
amf a Join linkedserver.source.dbo.table2 b On a.COM = b.COM
Where CATEGORY In ('1') And CODE In ('001','003','004','005')
And b.YR Between 2003 And 2004 And b.MON <= 1
) x
Where KEEP = 'Y'
Group By CATEGORY, YR"Jay" <webforum2000@.yahoo.com> wrote in message
news:9594a55e.0404230831.50bcabe0@.posting.google.c om...
> Hi
> when i try to run a query using linked servers, i get the following
> error.
> Server: Msg 125, Level 15, State 1, Line 1
> Case expressions may only be nested to level 10.
> I do have more than 10 case statements, it works fine when it is less
> than 10. can anyone tell me if there is a way to have more than 10
> case statements. thanks alot.
> Jay
> my query
> Select category, val, Sum(QTY) As QTY , yr
> From
> (
> Select val, QTY2 As QTY,
> KEEP = Case
> When code = '004' And ((YR > 2003) Or (YR = 2003 And MON > 12))
> Then 'N'
> When CODE = '005' And ((YR > 2003) Or (YR = 2003 And MON > 12))
> Then 'N'
> When CODE = '003' And ((YR > 2003) Or (YR = 2003 And MON > 12))
> Then 'N'
> When CODE = '017' And ((YR > 2003) Or (YR = 2003 And MON > 12))
> Then 'N'
> When CODE = '007' And ((YR > 2003) Or (YR = 2003 And MON > 12))
> Then 'N'
> When CODE = '008' And ((YR > 2003) Or (YR = 2003 And MON > 12))
> Then 'N'
> When CODE = '009' And ((YR > 2003) Or (YR = 2003 And MON > 11))
> Then 'N'
> When CODE = '010' And ((YR > 2003) Or (YR = 2003 And MON > 12))
> Then 'N'
> When CODE = '038' And ((YR > 2003) Or (YR = 2003 And MON > 12))
> Then 'N'
> When CODE = '032' And ((YR > 2003) Or (YR = 2003 And MON > 12))
> Then 'N'
> When CODE = '030' And ((YR > 2003) Or (YR = 2003 And MON > 12))
> Then 'N'
> When CODE = '018' And ((YR > 2003) Or (YR = 2003 And MON > 12))
> Then 'N'
> Else 'Y' End
> From
> amf a Join linkedserver.source.dbo.table2 b On a.COM = b.COM
> Where CATEGORY In ('1') And CODE In ('001','003','004','005')
> And b.YR Between 2003 And 2004 And b.MON <= 1
> ) x
> Where KEEP = 'Y'
> Group By CATEGORY, YR

Since most of your conditions are the same, have you tried something like
this?

Select category, val, Sum(QTY) As QTY , yr
From
(
Select val, QTY2 As QTY,
KEEP = Case
When code in ('004', '005, '003', '017', /* etc. */)
And ((YR > 2003) Or (YR = 2003 And MON > 12))
Else 'Y' End
From
amf a Join linkedserver.source.dbo.table2 b On a.COM = b.COM
Where CATEGORY In ('1') And CODE In ('001','003','004','005')
And b.YR Between 2003 And 2004 And b.MON <= 1
) x

Simon|||
hi
thanks for the suggestion. I have a problem, this is one of the query
where it is all the same, in a few others it varies a lot. i want to
know if the limitaion exists in sql using linked servers ( since it
works fine if i dont use linked servers and have them in the same
server). i want to get aroud this, so that i dont have to change all my
existing queries, and would hamper my using linked server. thanks.. any
suggestion?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Error with a simple JOIN query....

Hi!

I've a big problem by using the following query :

Code Snippet

public SqlCeResultSet selectRSQuery(String query)

{

SqlCeResultSet resultSet = initializeCommand(query).ExecuteResultSet(ResultSetOptions.Scrollable | ResultSetOptions.Updatable);

return resultSet;

}

SqlCeResultSet resultSet = sgb.selectRSQuery(

"SELECT p.pId, p.pLogin FROM Profiles p, ProfilesGroups pg, Groups g " +

"WHERE g.gId = pg.tpGroupId " +

"AND p.pId = pg.tpProfileId " +

"AND g.gProfileID = '" + app.Settings.Default.id + "'");

It return me this error :

Cannot generate an updatable cursor for the query because there is a non-standard join expression.

What can I do?

Thxx

Try using ANSI joins?

public SqlCeResultSet selectRSQuery(String query)

{

SqlCeResultSet resultSet = initializeCommand(query).ExecuteResultSet(ResultSetOptions.Scrollable | ResultSetOptions.Updatable);

return resultSet;

}

SqlCeResultSet resultSet = sgb.selectRSQuery(

"SELECT p.pId, p.pLogin

FROM Profiles p

inner join ProfilesGroups pg on pg.tpProfileID = p.pld

inner join Groups g on g.gld = pg.tpProfileId" +

"WHERE g.gProfileID = '" + app.Settings.Default.id + "'");

|||

hello!

I tried it... and it returns me :

Cannot generate an updatable cursor for the query because there is no updatable column.

thx for help

|||

re

if I remove the Options of the resultset.... It works..... but then It says me :

This operation is not valid because the cursor is not scrollable.

when I bind the resultset to my ListView :

lstViewTest.DataContext = resultSet;

edit : Here is the explanation of the problem :

Forward-only/Read-only Cursors

Forward-only/read-only cursors, referred to as forward-only cursors in earlier versions of SQL Server Compact Edition, are the fastest cursors, but cannot be updated.

The following is an example of how to obtain a forward-only/read-only cursor by using ADO.NET:

cmd.CommandText = "Select * from tablename";

SqlCeResultSet rs = cmd.ExecuteResultSet(ResultSetOptions.None);

Note You cannot create read-only cursors on query that returns only read only columns because internally all SQL Server Compact Edition cursors are updatable. SQL Server Compact Edition cannot update read-only columns returned in the SqlCeResultSet. Therefore, it would fail with the error "Cannot generate an updatable cursor for the query because there is no updatable column."

|||

how can I fill my ListView without using a ResultSet ?

thx...

|||ExecuteReader returns a DataReader that can be fed to the DataTable.Load. Either that or create a DataAdapter and use the Fill method to create a DataTable. Bind the DataTable to the list.|||

Hi!

I decided to use ObservableCollection! I load my objects with a sqlcedatareader in a ObservableCollection, and then bind it in xaml mode!

The disadvantage of this method is that I lost "the design preview" in Blend

Here is my code :

Code Snippet

public class ProfileI : INotifyPropertyChanged

{

private String _id;

private String _profileInfoID;

private String _login;

private String _password;

public ProfileI() { }

public ProfileI(string id, string profileInfoID, string login)

{

Id = id;

ProfileInfoID = profileInfoID;

Login = login;

}

public ProfileI(string id, string profileInfoID, string login, string password)

{

Id = id;

ProfileInfoID = profileInfoID;

Login = login;

Password = password;

}

#region Properties Getters/Setters

public String Login

{

get

{

return _login;

}

set

{

if (value != "")

{

if (value.Length < 5)

{

throw new ArgumentException(app.Resources.errorLoginTooSmall);

}

_login = value;

OnPropertyChanged("Login");

}

}

}

public String Password

{

get

{

return _password;

}

set

{

if (value != "")

{

if (value.Length < 5)

{

throw new ArgumentException(app.Resources.errorLoginTooSmall);

}

_password = value;

OnPropertyChanged("Password");

}

}

}

public string ProfileInfoID

{

get

{

return _profileInfoID;

}

set

{

_profileInfoID = value;

OnPropertyChanged("ProfileInfoID");

}

}

public string Id

{

get

{

return _id;

}

set

{

_id = value;

OnPropertyChanged("Id");

}

}

#endregion

public event PropertyChangedEventHandler PropertyChanged;

protected void OnPropertyChanged(String propertyName)

{

if (this.PropertyChanged != null)

PropertyChanged(this, new PropertyChangedEventArgs(propertyName));

}

}

public class myProfilesI :

ObservableCollection<ProfileI>

{

public myProfilesI()

{

// On r?cup?re les "profiles-amis" de l'utilisateur

SingleDatabase sd = SingleDatabase.getInstance();

SqlCeDataReader sdr = sd.selectDRQuery(

"SELECT p.pId, p.pProfileInfoID, p.pLogin FROM Profiles p, ProfilesGroups pg, Groups g " +

"WHERE g.gId = pg.tpGroupId " +

"AND p.pId = pg.tpProfileId " +

"AND g.gProfileID = '" + app.Settings.Default.id + "'");

while (sdr.Read())

{

Add(new ProfileI(sdr["pId"].ToString(), sdr["pProfileInfoID"].ToString(), sdr["pLogin"].ToString()));

}

}

}

And my XAML file :

Code Snippet

<Window

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

xmlns:d="http://schemas.microsoft.com/expression/blend/2006"

xmlns:ToDo="clr-namespace:ToDo"

x:Class="ToDo.ToDoConfig"

x:Name="Window"

Title="ToDoConfig"

Width="640" Height="480">

<Window.Resources>

<ObjectDataProvider x:Key="MyProfilesInfoDataSource"

ObjectType="{x:Type ToDo:myProfilesI}"/>

</Window.Resources>

<Grid x:Name="LayoutRoot">

<Grid.RowDefinitions>

<RowDefinition Height="0.169*"/>

<RowDefinition Height="0.831*"/>

<RowDefinition Height="30"/>

</Grid.RowDefinitions>

<ToDo:Footer HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch" Width="Auto" Height="Auto" Grid.Row="2"/>

<ToDo:Header HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch" Grid.RowSpan="1"/>

<ListView ItemsSource="{Binding Source={StaticResource MyProfilesInfoDataSource}}" IsSynchronizedWithCurrentItem="True" Grid.Row="1">

<ListView.View>

<GridView>

<GridViewColumn DisplayMemberBinding=

"{Binding Path=Login}"

Header="Login" Width="100"/>

</GridView>

</ListView.View>

</ListView>

</Grid>

</Window>

Also note that it's not possible to use construtors like this :

Code Snippet

public ProfileI(string id, string profileInfoID, string login)

: this(id, profileInfoID, login, null)

{}

public ProfileI(string id, string profileInfoID, string login, string password)

{

Id = id;

ProfileInfoID = profileInfoID;

Login = login;

Password = password;

}

If you have a solution to conserve the design in Blend, I will be happy .

+++

error while working with dynamic query in report

Hi all,
I am trying to add report parameter to my report.I am getting "cannot
set the command text for dataset ''dataset_name " this kind of error. I am
working with sql server 2005.I found this tutorial in Books Online->sql
server tutorials - >Reporting Services Tutorials - >Using a dynamic query in
a report.
Can u plz tell me why i am getting this kind of error.
Thnx.YOu should repost this in the Reporting Services Group. But also include the
actual Query you are using...
ie
=" Select * From titles"
Wayne Snyder MCDBA, SQL Server MVP
Mariner, Charlotte, NC
I support the Professional Association for SQL Server ( PASS) and it''s
community of SQL Professionals.
"supriya" wrote:

> Hi all,
> I am trying to add report parameter to my report.I am getting "cann
ot
> set the command text for dataset ''dataset_name " this kind of error. I am
> working with sql server 2005.I found this tutorial in Books Online->sql
> server tutorials - >Reporting Services Tutorials - >Using a dynamic query
in
> a report.
> Can u plz tell me why i am getting this kind of error.
> Thnx.
>
>

Sunday, February 19, 2012

Error while shrinking transaction log

Hi all,

while I shrinked transaction log using command "dbcc shrinkfile (logfile)" in query analyzer, the error message " cannot find logfile in sysfiles" was shown up.

The I list out content of sysfiles, and found that sysfiles doesn't contain logfile.

Can anybody tell me how to eliminate error in order to shrink transaction log?

Thanks in advances.

PaulYou need to enter the correct filename for your tempdb database. Default is templog. Right click on tempdb to find your correct filename.
Try:
USE tempdb
go
DBCC SHRINKFILE (TEMPLOG)|||Martsar,

Thanks for your input.

I checked and found that my syntax and log file name were correct, but preceding error message was still there. But I did successfully to shrink TEMPLOG.|||to check the filenames of db and log execute from your database:

use yourDB
go
sp_helpfile

The syntax to shrink db and log is:
DBCC SHRINKDATABASE (N'dbName/or logName', 0)

Also, try to shrink log in EM.

Error while running Query

Hi,

SQL Server 7
When i ran a query in query analyzer i am getting the below error.
once i closed and opened the query analyzer and ran the same query it worked fine.

pls the error which i got in first time.

Microsoft][ODBC SQL Server Driver]Unknown token received from SQL Server
[Microsoft][ODBC SQL Server Driver]Protocol error in TDS stream
[Microsoft][ODBC SQL Server Driver]Protocol error in TDS stream
[Microsoft][ODBC SQL Server Driver]Protocol error in TDS stream
[Microsoft][ODBC SQL Server Driver]Protocol error in TDS stream
[Microsoft][ODBC SQL Server Driver]Protocol error in TDS stream
[Microsoft][ODBC SQL Server Driver]Protocol error in TDS stream
[Microsoft][ODBC SQL Server Driver]Protocol error in TDS stream
[Microsoft][ODBC SQL Server Driver]TDS buffer length too large
[Microsoft][ODBC SQL Server Driver]TDS buffer length too large
[Microsoft][ODBC SQL Server Driver]TDS buffer length too large
[Microsoft][ODBC SQL Server Driver]TDS buffer length too large
[Microsoft][ODBC SQL Server Driver]Unknown token received from SQL Server
[Microsoft][ODBC SQL Server Driver]Unknown token received from SQL Server
[Microsoft][ODBC SQL Server Driver]Unknown token received from SQL Server
[Microsoft][ODBC SQL Server Driver]Unknown token received from SQL Server
[Microsoft][ODBC SQL Server Driver]Unknown token received from SQL Server
[Microsoft][ODBC SQL Server Driver]TDS buffer length too large
[Microsoft][ODBC SQL Server Driver]TDS buffer length too large
[Microsoft][ODBC SQL Server Driver]TDS buffer length too large

Pls help me in this

TIA
AdilSo, after you reopened QA the same query ran with no errors? Are you suspecting you're going to get it again?|||hi
thanks for the reply

yes, i'm worried if it comes again whats the solution for it.
pls help me out.

TIA|||The problem seems to be that you've got some bits stuck in your network cable. Remove the cable, shake it vigorously in all four cardinal compass points (north, east, south, and west), and plug it back in. Things should work just fine then!

On a slightly more serious note, removing the network cable will actually fix the problem in most cases. There was some kind of communication error, possibly lost data/framing error/digi-voodoo/etc. When you remove the network cable for any significant amount of time (over a few seconds), the NIC resets. When the cable is reattached, the NIC reconnects, and whatever problem there was is magically gone.

If nothing else, the attention that you get when everybody thinks that you've clearly lost what little mind you might have once had, then your bizzare behavior appears to fix the problem will get you lots of digi-voodoo status.

-PatP|||that's an interesting solution, but considering the real reason for the above error actually very precise. now, here's your reference material (http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q176/2/56.asp&NoWebContent=1) in this regard.|||Pat Phelan, you need to be more carefull about your advice. I followed your intructions and got bits all over my carpet. They are extremely hard to get out, and since the dang things carry a static charge they stick to my cat and he has tracked them all over the house. On a positive note, they seemed to pass through his digestive tract pretty quickly.

Wednesday, February 15, 2012

Error while executing a a query string using EXEC statement

Hi,

I have written a stored proc to bulk insert the data from a data file.

I have a requirement that i need to insert the data into a table of which the name is not known. I mean to say that the table name will be passed as a parameter to the stored proc. And also i need to insert the date that will also be passed as the parameter to the stored proc

The follwing statement works fine if i give the table name directly in the query

Code Snippet

DECLARE @.LastUpdate varchar(20)

SET @.LastUpdate = 'Dec 11 2007 1:20AM'

INSERT INTO Category

SELECT MSISDN, @.LastUpdate FROM OPENROWSET( BULK '\\remotemachine\datafile.txt',

FORMATFILE = '\\remotemachine\FormatFile.fmt',

FIRSTROW = 2) AS a

To satisfy my requirement ( i.e passing the table name dynamically , and the date) , i have formed the query string ( exact one as above ) and passing it to EXEC statement. But its failing as explained below

Code Snippet

@.Category - Will be passed as a parameter to the stored proc

DECLARE @.vsBulkSQL VARCHAR(MAX)

DECLARE @.LastUpdate varchar(20)

SET @.LastUpdate = 'Dec 11 2007 1:20AM'

SELECT @.vsBulkSQL ='INSERT INTO '+ @.Category + ' SELECT MSISDN, ''' + @.LastUpdate +''' FROM OPENROWSET ' + '( BULK ' + '''' + '\\remotemachine\datafile.txt'+ ''''+ ' ,' +

+ ' FORMATFILE ' + '=' + ''''+ '\\remotemachine\FormatFile.fmt'+ ''''+ ',' +

' FIRSTROW ' + '=' + '2' + ')' + ' AS a'

Print @.vsBulkSQL - This prints the folliwing statement

INSERT INTO Category SELECT MSISDN, 'Dec 11 2007 1:20AM' FROM OPENROWSET ( BULK '\\remotemachine\DataFile.txt' , FORMATFILE ='\\remotemachine\FormatFile.fmt', FIRSTROW =2) AS a

Exec @.vsBulkSQL - This statement gives the following error

The name 'INSERT INTO Sports SELECT MSISDN, 'Dec 11 2007 1:20AM' FROM OPENROWSET ( BULK '\\remotemachine\Second.txt' , FORMATFILE ='\\remotemachine\FormatFile.fmt', FIRSTROW =2) AS a' is not a valid identifier.

Can any one please point out where am i doing wrong? Or do i need to do anything else to achive the same

~Mohan

Does it work if you alias the @.LastUpdate value?

|||

I suspect you need to execute the query with

EXEC (@.vsBulkSQL)

You have left out the parentheses, and when you do that, EXEC expects the variable to hold a procedure name, not a query string.

Steve Kass

Drew University

www.stevekass.com

|||

Steve,

Good catch. Its working now if i have the string etween ( and ).

Thanks a lot

~Mohan