Showing posts with label command. Show all posts
Showing posts with label command. Show all posts

Monday, March 26, 2012

Rowcount and SQLDataReader

Hi, from what I can find, there isn't a way to get the number of rows returned from a SQLDataReader command. Is this correct? If so, is there a way around this? My SQLDataReader command is as follows:

Dim commandIndAsNew System.Data.OleDb.OleDbDataAdapter(strQueryCombined, connInd)

Dim commandSQLAsNew SqlCommand("GetAssetList2", connStringSQL)

Dim resultDSAsNew Data.DataSet()

'// Fill the dataset with values

commandInd.Fill(resultDS)

'// Get the XML values of the dataset to send to SQL server and run a new query

Dim strXMLAsString = resultDS.GetXml()

Dim xmlFileListAs SqlParameter

Dim strContainsClauseAs SqlParameter

'// Create and execute the search against SQL Server

connStringSQL.Open()

commandSQL.CommandType = Data.CommandType.StoredProcedure

commandSQL.Parameters.Add("@.xmlFileList", Data.SqlDbType.VarChar, 1000).Value = strXML

commandSQL.Parameters.Add("@.strContainsClause", Data.SqlDbType.VarChar, 1000).Value = strContainsConstruct

Dim sqlReaderSourceAs SqlDataReader = commandSQL.ExecuteReader()

results.DataSource = sqlReaderSource

results.DataBind()

connStringSQL.Close()

And the stored procedure is such:

DROPPROC dbo.GetAssetList2;

GO

CREATEPROC dbo.GetAssetList2

(

@.xmlFileListvarchar(1000),

@.strContainsClausevarchar(1000)

)

AS

BEGIN

SETNOCOUNTON

DECLARE @.intDocHandleint

EXECsp_xml_preparedocument @.intDocHandleOUTPUT, @.xmlFileList

SELECTDISTINCT

AssetsMaster.AssetMasterUID,

SupportedFiles.AssetPath,

FROM

AssetsMaster,

OPENXML(@.intDocHandle,'/NewDataSet/Table',2)WITH(FILENAMEvarchar(256))AS x,

SupportedFiles

WHERE

AssetsMaster.AssetFileName= x.FILENAME

AND AssetsMaster.Extension= SupportedFiles.Extension

UNION

SELECTDISTINCT

AssetsMaster.AssetMasterUID,

SupportedFiles.AssetPath,

FROM

AssetsMaster,

OPENXML(@.intDocHandle,'/NewDataSet/Table',2)WITH(FILENAMEvarchar(256))AS x,

SupportedFiles

WHERE

AssetsMaster.AssetFileName<> x.FILENAME

ANDCONTAINS((Description, Keywords), @.strContainsClause)

AND AssetsMaster.Extension= SupportedFiles.Extension

ORDERBY AssetsMaster.DownloadsDESC

EXECsp_xml_removedocument @.intDocHandle

END

GO

How can I access the number of rows returned by this stored procedure?

Thanks,

James

I would suggest changing your datareader into a dataset. Then you can bind to the dataset, and also check how many rows are in it.|||

Thanks Motley. What is wrong with this? I am calling a stored SELECT procedure. It says there is a syntax error.

Dim connStringSQLAsNew SqlConnection("Data Source=*;Database=*;User ID=*;Password=*;Trusted_Connection=*")

'// Create the new OLEDB connection to Indexing Service

Dim commandSQLAsNew SqlCommand("GetAssetList2", connStringSQL)

Dim resultDSAsNew Data.DataSet()

Dim resultDAAsNew SqlDataAdapter()

'// Fill the dataset with values from the previous query

commandInd.Fill(resultDS)

'// Get the XML values of the dataset to send to SQL server and run a new query

Dim strXMLAsString = resultDS.GetXml()

Dim xmlFileListAs SqlParameter

Dim strContainsClauseAs SqlParameter

'// Create and execute the search against SQL Server

commandSQL.Parameters.Add("@.xmlFileList", Data.SqlDbType.VarChar, 1000).Value = strXML

commandSQL.Parameters.Add("@.strContainsClause", Data.SqlDbType.VarChar, 1000).Value = strContainsConstruct

resultDA.SelectCommand = commandSQL

resultDA.Fill(resultDS)

Dim sourceAsNew Data.DataView(resultDS.Tables(0))

resultCount.Text = source.Count.ToString

results.DataSource = source

results.DataBind()

|||

Never mind, I got it by added

commandSQL.CommandType = Data.CommandType.StoredProcedure

But now I get one extra row returned per query. It's empty. Any ideas?

Wednesday, March 21, 2012

Row not found at Subscriber

When we inserted a row at the Publisher -- this is error we got:
The row was not found at the Subscriber when applying the replicated command.
Since this was a new row, why would I get this error.
Unrelated question: we do not proprogate changes from the Subscriber to the
Publisher. However, there is one field that is allowed to be updated at the
subscriber. All other data is read-only.
What effect will this have on replication. That same field is replicated.
Logic tells me the updated subsriber field will be overwritten by the next
replication.
WR
When you updated the row at the subscriber, did you change its primary key?
If you did, this is probably why you are getting this error. Replication
uses the PK to determine which row on the subscriber to modify. You can
enable logging as per this kb article to determine which row replication is
failing on.
http://support.microsoft.com/default...b;en-us;312292
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"WhiskyRomeo" <WhiskyRomeo@.discussions.microsoft.com> wrote in message
news:1BBA4901-21F7-4023-AFAA-811F3F78BB31@.microsoft.com...
> When we inserted a row at the Publisher -- this is error we got:
> The row was not found at the Subscriber when applying the replicated
command.
> Since this was a new row, why would I get this error.
> Unrelated question: we do not proprogate changes from the Subscriber to
the
> Publisher. However, there is one field that is allowed to be updated at
the
> subscriber. All other data is read-only.
> What effect will this have on replication. That same field is replicated.
> Logic tells me the updated subsriber field will be overwritten by the next
> replication.
> --
> WR
|||I will enable logging; but the primary key cannot be updated (it is an
identity field at the publisher database).
Adminstrators of a local Windows .Net application can setup users who are
authorized to view data on the web in their Windows application. Data that
is viewed on the web is Pushed to a database running on a Server on the
internet. When a web user is initially set up in the local windows
application, the password for that user is initially set.
When the web user logs in for the first time he must change his password.
That is the only write activity allowed on the web (the subscriber). My
first question related to the fact, if that User was later updated at that
local application, wouldn't that overwrite any password update at the
subscriber site. If this is the case, can I allow updating the publisher for
only that column or record?
Concerning the other errror: I do recall deleting the same contact via EM
at both the Windows site and the Web site. Could this have caused this
problem? If so, how can I repair it?
wrl
"Hilary Cotter" wrote:

> When you updated the row at the subscriber, did you change its primary key?
> If you did, this is probably why you are getting this error. Replication
> uses the PK to determine which row on the subscriber to modify. You can
> enable logging as per this kb article to determine which row replication is
> failing on.
> http://support.microsoft.com/default...b;en-us;312292
> --
> Hilary Cotter
> Looking for a SQL Server replication book?
> http://www.nwsu.com/0974973602.html
> Looking for a FAQ on Indexing Services/SQL FTS
> http://www.indexserverfaq.com
> "WhiskyRomeo" <WhiskyRomeo@.discussions.microsoft.com> wrote in message
> news:1BBA4901-21F7-4023-AFAA-811F3F78BB31@.microsoft.com...
> command.
> the
> the
>
>

Friday, March 9, 2012

row count different from QA and EM

I can not think of the command that will update something(?) so that the
data that is displayed in EM will be udpated. The problem is EM says there
XX amount of free space and QA says different. I have seen this in the past
but can't remember things these days
Right click on the database on click 'Refresh'
Brad Feaker
Ex nihilo, nihil fit
"CD" wrote:

> I can not think of the command that will update something(?) so that the
> data that is displayed in EM will be udpated. The problem is EM says there
> XX amount of free space and QA says different. I have seen this in the past
> but can't remember things these days
>
>
|||DBCC UPDATEUSAGE
-Sue
On Fri, 14 Jan 2005 12:53:57 -0600, "CD"
<mcdye1@.hotmail.nospam.com> wrote:

>I can not think of the command that will update something(?) so that the
>data that is displayed in EM will be udpated. The problem is EM says there
>XX amount of free space and QA says different. I have seen this in the past
>but can't remember things these days
>
|||thank you Sue,
"Sue Hoegemeier" <Sue_H@.nomail.please> wrote in message
news:ns5gu09hq843ir1pd6s9sfla6gfbaev7ro@.4ax.com... [vbcol=seagreen]
> DBCC UPDATEUSAGE
> -Sue
> On Fri, 14 Jan 2005 12:53:57 -0600, "CD"
> <mcdye1@.hotmail.nospam.com> wrote:
there[vbcol=seagreen]
past
>

row count different from QA and EM

I can not think of the command that will update something(?) so that the
data that is displayed in EM will be udpated. The problem is EM says there
XX amount of free space and QA says different. I have seen this in the past
but can't remember things these days Right click on the database on click 'Refresh'
Brad Feaker
Ex nihilo, nihil fit
"CD" wrote:

> I can not think of the command that will update something(?) so that the
> data that is displayed in EM will be udpated. The problem is EM says the
re
> XX amount of free space and QA says different. I have seen this in the pa
st
> but can't remember things these days
>
>|||DBCC UPDATEUSAGE
-Sue
On Fri, 14 Jan 2005 12:53:57 -0600, "CD"
<mcdye1@.hotmail.nospam.com> wrote:

>I can not think of the command that will update something(?) so that the
>data that is displayed in EM will be udpated. The problem is EM says ther
e
>XX amount of free space and QA says different. I have seen this in the pas
t
>but can't remember things these days
>|||thank you Sue,
"Sue Hoegemeier" <Sue_H@.nomail.please> wrote in message
news:ns5gu09hq843ir1pd6s9sfla6gfbaev7ro@.
4ax.com...
> DBCC UPDATEUSAGE
> -Sue
> On Fri, 14 Jan 2005 12:53:57 -0600, "CD"
> <mcdye1@.hotmail.nospam.com> wrote:
>
there[vbcol=seagreen]
past[vbcol=seagreen]
>

row count different from QA and EM

I can not think of the command that will update something(?) so that the
data that is displayed in EM will be udpated. The problem is EM says there
XX amount of free space and QA says different. I have seen this in the past
but can't remember things these days :(Right click on the database on click 'Refresh'
Brad Feaker
Ex nihilo, nihil fit
"CD" wrote:
> I can not think of the command that will update something(?) so that the
> data that is displayed in EM will be udpated. The problem is EM says there
> XX amount of free space and QA says different. I have seen this in the past
> but can't remember things these days :(
>
>|||DBCC UPDATEUSAGE
-Sue
On Fri, 14 Jan 2005 12:53:57 -0600, "CD"
<mcdye1@.hotmail.nospam.com> wrote:
>I can not think of the command that will update something(?) so that the
>data that is displayed in EM will be udpated. The problem is EM says there
>XX amount of free space and QA says different. I have seen this in the past
>but can't remember things these days :(
>|||thank you Sue,
"Sue Hoegemeier" <Sue_H@.nomail.please> wrote in message
news:ns5gu09hq843ir1pd6s9sfla6gfbaev7ro@.4ax.com...
> DBCC UPDATEUSAGE
> -Sue
> On Fri, 14 Jan 2005 12:53:57 -0600, "CD"
> <mcdye1@.hotmail.nospam.com> wrote:
> >I can not think of the command that will update something(?) so that the
> >data that is displayed in EM will be udpated. The problem is EM says
there
> >XX amount of free space and QA says different. I have seen this in the
past
> >but can't remember things these days :(
> >
>

Saturday, February 25, 2012

Rougue CR/LF in my bcp output flat file!?!?!

The following bcp command is present in an NT job I have scheduled each daybcp "EXECUTE DailyProd.dbo.GetIndexComponentStocks_XML '2006-04-05'" queryout "D:\TABLES\INPUTAP\IndexComponentStocks.wrk"
-S(local) -c -T -o"..\IndexComponenet_XML_LOG.txt" -e"..\IndexComponenet_XML_ERR.txt"
My trouble is that every 2034 characters the output contains a :0D:0A (CR/Linefeed).

Other than that all the output data looks peachy.

Is there some line size setting I am missing (would it be packetsize?)?

Ideally I would just like to not have any CR/LF in my file at all...is there some way to turn it off? I see there are flags to set to change the column and row terminators, but how to turn them OFF?

Thanks much!
PaulYup, just had to add the -r and -c flags without any character following them to turn 'em off.