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

Thursday, March 22, 2012

A URL expression problem with a Jump to command

I have a report that uses the table control, the last column has id's for
dealcompanies in it(Fields!res_dealCompanyid.Value). When the user clicks on
any of the other Columns in a row I would like to be able to grab the id from
the last column in the row and insert it into the expression for the Jump to
url feature.
this url works fin
="javascript:void(window.open('http://sandbox:82/EE2/DealCompany.aspx?id={535d58cc-a1b3-da11-9864-001320020c86}','_blank'))"
this one gives me an Error on pag
="javascript:void(window.open('http://sandbox:82/EE2/DealCompany.aspx?id={'&Fields!res_dealCompanyid.Value&'}','_blank'))"
How can I find out what is wrong
MikeI got this to work, my problem was that the dealCompanyid value was not a
string so I had to do a Fields!res_dealcompanyid.Value.tostring() then it
worked fine.
Parameters!CRMServer.Value just holds a Server info
="javascript:void(window.open('http://" & Parameters!CRMServer.Value &
"/EE2/DealCompany.aspx?id=" & Fields!res_dealcompanyid.Value.tostring() & "',
'_blank'))"
"Hotwheels" wrote:
> I have a report that uses the table control, the last column has id's for
> dealcompanies in it(Fields!res_dealCompanyid.Value). When the user clicks on
> any of the other Columns in a row I would like to be able to grab the id from
> the last column in the row and insert it into the expression for the Jump to
> url feature.
> this url works fine
> ="javascript:void(window.open('http://sandbox:82/EE2/DealCompany.aspx?id={535d58cc-a1b3-da11-9864-001320020c86}','_blank'))"
> this one gives me an Error on page
> ="javascript:void(window.open('http://sandbox:82/EE2/DealCompany.aspx?id={'&Fields!res_dealCompanyid.Value&'}','_blank'))"
> How can I find out what is wrong
> Mike
>

Sunday, March 11, 2012

A SqlDataReader is returning an int, when it should be returning a tinyint

I am opening a simple command against a view which joins 2 tables, so that I can return a column which is defined as a tinyint in one of the tables. The SELECT looks like this:

SELECT TreatmentStatusFROM vwReferralWithAdmissionDischarge
WHERE ClientNumber = 138238AND CaseNumber = 1AND ProviderNumber = 89

The TreatmentStatus column is a tinyint. When I execute that above SQL SELECT statement in SQL Server Management Studio (I am using SQL Server 2005) I get a value of 2. But when I execute the same SQL SELECT statement as a part of a SqlDataReader and SqlCommand, I get a return data type of integer and a value of 1.

Why?

If you are just reteieving one value you might want to use ExecuteScalar which is faster and has less overhead than ExecuteReader.

|||

Try this:

int numericValue = System.Convert.ToInt32(yourDataReader.GetByte(0));

Cheers

|||

humormuch:

Try this:

int numericValue = System.Convert.ToInt32(yourDataReader.GetByte(0));

Cheers

I forgot to mention, in my original post, that I was using the GetByte() method of the SqlDataReader object, but that raised the following error message:

"Specified cast is not valid"

That's why I brought up the whole thing about knowing that the column was atinyint, but that the SqlDataReader in my ASP.NET 2.0 page is returning aint value instead, which I simply donot understand. Here is the relevant code snippet:

Dim sbAs StringBuilder =New StringBuilder("SELECT TreatmentStatus FROM vwReferralWithAdmissionDischarge ")sb.Append(String.Format("WHERE ClientNumber = {0} ", lClientNumber))sb.Append(String.Format("AND CaseNumber = {0} ", byCaseNumber))sb.Append(String.Format("AND ProviderNumber = {0}", nProviderNumber))Dim cmCheckTreatmentStatusAs SqlCommand =New SqlCommand(sb.ToString(), cn)cmCheckTreatmentStatus.CommandType = CommandType.TextDim sdrCheckTreatmentStatusAs SqlDataReader = cm.ExecuteReader()sdrCheckTreatmentStatus.Read()If sdrCheckTreatmentStatus.IsDBNull(0)Then'NOOPElseDim byTreatmentStatusAs Byte = sdrCheckTreatmentStatus.GetByte(0)'other stuff occurs hereEnd If

It is the line "Dim byTreatmentStatusAs Byte = sdrCheckTreatmentStatus.GetByte(0)" which is raising the error.

|||

Never mind, I found the mistake. It was a stupid mistake on my part. I had created a SqlCommand calledcmCheckTreatmentStatus, and then ran the ExecuteReader() method on another SqlCommand I defined earlier, calledcm.

I'm sorry everyone.

|||

DoctorWho:

Never mind, I found the mistake. It was a stupid mistake on my part. I had created a SqlCommand calledcmCheckTreatmentStatus, and then ran the ExecuteReader() method on another SqlCommand I defined earlier, calledcm.

I'm sorry everyone.

No problem. I remember I have done that quite a few times...

Thursday, March 8, 2012

A Simple Strange Query..........

I am having in writing a simple select command......
here's My Problem

I am using the ASP SQLDataSources in VS2005... and my need is that i need to show Products details in a Gridview.....
Actually through QueryString a StoreID is being fetched.... and the Products under those StoreID are shown.... if there is nothing in query string then it should show all the results... ...... It means that my querystring should be something like this

select * from tblProducts where StoreID = <xyz>

and <xyz> should be some thing that could show all the rows in that table ...... i mean that it should show all the possible results that can be shown through...

select * from tblProducts

Dhaliwal

1) Your select command should be a in stored procedure which takes the StoreId as an argument.

2) You should never use SELECT * in the query - only the columns being used in the Gridview should be included.

3) The tbl prefix on tblProducts is depreciated. Also it should be in the singular as each row contains information on a single product. A better name would be Product.

4) The switch is much easier to achieve that is commonly imagined. Assuming that StoreId is an Integer primary key then the lowest value will be 1. Your stored procedure will then contain

IF @.StoreId > 0

SELECT A, B, C FROM Product Where StoreId = @.StoreId

ELSE

SELECT A, B, C FROM Product

(If should be noted that this is not very suitable for a database with a high volume of queries - in this case you should use two stored procedures one for all records and one for a list select selective by store.)

5) Run the stored procedure getting a dataset and assign the dataset to the GridView.

|||hi there,
thank you very much for such a quick reply..........

I fully agree with you that using Stored procedured is a good Idea/Methodology
Actually i used to do these task through coding each time but i really want to try these new components and see how they works...(under all kind of situations).... so is it possible without using stored procedure......

and 1 more thing i want to ask...... i couldn't get your 3rd point totally....... what r u trying to say in that.... would you please elaborate it... wht the prefixtbl is depreciated...!!!|||

Here is how you can do it:

 <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:yourConnectionString%>"CancelSelectOnNullParameter="false" SelectCommand="SELECT * FROM tblProducts WHERE productID=ISNULL(@.productID,productID)"> <SelectParameters> <asp:QueryStringParameter Name="productID" QueryStringField="productID" /> </SelectParameters> </asp:SqlDataSource>
|||

Dhaliwal:

hi there,
thank you very much for such a quick reply..........

I fully agree with you that using Stored procedured is a good Idea/Methodology
Actually i used to do these task through coding each time but i really want to try these new components and see how they works...(under all kind of situations).... so is it possible without using stored procedure......

and 1 more thing i want to ask...... i couldn't get your 3rd point totally....... what r u trying to say in that.... would you please elaborate it... wht the prefixtbl is depreciated...!!!

Hi Dhaliwal,
I think that the use of a stored procedure would be good because all your logic would be into the stored procedure. By other hand The SqlDataSource control is a very good control, very easy to use but there is something I do not like, it embeds the SQL code into the presentation layer (aspx). I would suggest that you could take a look atwww.sqlnetframework.com. There is a SqlStoreDataSource control which works in the same way that the SqlDataSource control but it doesn't embed the SQL code into the presentation layer. The SqlStoreDataSource control creates a repository where all your SQL code is stored. You can re-use your SQL code in other application (e.g. Windows app). The SqlDataSource control is very easy to use, to learn and it helps you to create an application with a good architecture.

I hope it helps you in your projects.Yes


Luis Ramirez.
www.sqlnetframework.com

|||Hi Luis....

Thanks for expressing your views about howData should be fetched from Database and as i said earlier i agree that using Store Proc is a better method... but i was just practicing and really wanted to try SQLDatasource completely. Moreover i was kean to know about SQL Query that could result in what i was looking for....... and whatLimno provided was exactly i was looking for...... i.e usingIsNULL in select Query (Nice Trick)

And also Thanks alot for sharing views about the SQLDataSource controls(Benifits/Limitations... etc)|||

There was a time when the prefix was used to make it obvious what were the table names, however in the statement

SELECT Avalue FROM Bert WHERE Id = 1

it is obvious that Bert is a table. The use of the tbl was quite unnecessary. Table name can get quite long enough without using tbl!

There are some contexts where some form of prefix is useful, however given a modern utility such as SQL Server Management Studio, which lists tables separatly from say stored procedures, the tbl prefix is unnecessary.

HTH

A severe error occurred on the current command. The results, if any, should be discarded.

Hi,

I am hosting my ASP.NET application on a Host and after some time I get this error
(Don't get it on my development machine):

A severe error occurred on the current command. The results, if any, should be discarded.

And then it says this on the same page:

Exception Details: System.Data.SqlClient.SqlException: A severe error occurred on the current command. The results, if any, should be discarded.

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

[SqlException: A severe error occurred on the current command. The results, if any, should be discarded.]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) +643
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) +9
ASPNetPortal.PortalSettings..ctor(Int32 tabIndex, Int32 tabId)
ASPNetPortal.Global.Application_BeginRequest(Object sender, EventArgs e)
System.Web.SyncEventExecutionStep.Execute() +60
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

I thought this is a problem with max pool size and I did it max pool size = 5000, now application runs ok for some time and then produces this error but some times this comes very soon.

As a solution, I have to copy my dll in bin directory again and application restarts and works properly but then after some time this happenes again.

Please let me know whats the problem.
I checked all of my SqlDataReaders and SqlConnections are closed properly.

Any help would be appreciated.

Thanks.

Rahul.Rahul,

Getting a similar problem. I've narrowed it down to 3 stored procedures I wrote, others work fine. In the win2k server event view you should see a message

Error: 17805, Severity: 18, State: 3
2002-09-05 10:39:41.68 ods Invalid buffer received from client.

I've noticed that the StroProc often hangs when using the 'run stored procedure' function in the Explorer window in the V NET IDE. However the data still gets added. This would suggest the StorProc isn't returning a result to the code in time.

Like you our test server is fine. This runs SQL Server 2000 Developer Edition (SP1)

The production server runs SQL Server 7.0 (SP4)

Do your StroProcs use char or varchar types with a 50+ size or have a large number of parameters?

Regards

Richard|||Hi Richard,

Thanks a lot for your support.
Well! Certainly I am using varchar for 50+ size.

But I think I figured out the problem (still not sure) because since last two days I didn't get this error message, for this success I made some changes to my code.

If you think to discuss these changes would be worth then please let me know.

Thanks a lot again.

Rahul.|||So, did anyone ever figure the answer to this problem? I'm having the same issue, development server works fine (SQL2K), production server craps out (SQL7) with errors "Invalid Buffer received from client"|||If anyone's tracking this thread, here's an update: I moved the database to another production server running SQL2000, and it runs flawlessly. So the root cause is something in the way SQL7 handles SP's from .Net. More updates to come as I find them...|||We are having the same problem (with tables in our .NET Forums database) and found this info on a microsoft newsgroup)
Unfortunately the stricter datatype processing is a side effect of the 031
patch. We're working on a KB article to explain the behavior and scope.
Here is a draft of our work in progress:

KB 827366 – “Error 17805: Invalid Buffer Received from Client? Error
Message in SQL”

-----------------------
--

The information in this article applies to:

- Microsoft .NET Framework 1.0 (Version: 1.0)

- Microsoft .NET Framework 1.1

-----------------------
--

SYMPTOMS

========

When you use the SqlClient .NET Framework classes, the following error
messages may appear in the SQL Server 2000 error log:

Error: 17805, Severity: 20, State: 3

Invalid buffer received from client.

The following corresponding errors may appear in the client .NET
application:

System.Data.SqlClient.SqlException: A severe error occurred on
the current command. The results, if any, should be discarded

-or-

System.Data.SqlClient.SqlException: Procedure or function
spXXXX has too many arguments specified.

Note If you are using the .NET Framework 1.1 you only see the last error
message.

CAUSE

=====

There are three causes for these errors:

- You use SqlClient classes in a Finalize method or C# destructor. Do not
use any managed classes in a Finalize method or C# destructor.

- You do not specify an explicit SQLDbType for the parameters. In this
case, the SqlClient .NET provider tries to select the correct SQLDbType
based on the data that is passed and it will fail.

- If the size of the parameter that is specified explicitly in the .NET
code is more than the maximum allowable size for the data type in the SQL
Server.

- For example: According to SQL Server Books Online, nvarchar is a
Variable-length Unicode character data of n characters. n must be a value
from 1 through 4,000 If you specify a size that is more than 4000 for an
nvarchar parameter, then you will receive the error message that the
"Symptoms" section describes.

The following code also demonstrates how these errors can occur:

Stored Procedure

--------

PROCEDURE spParameterBug @.myText Text AS

Insert Into ParameterBugTable (TextField) Values
(@.myText)

Code

---

static void Main(string[] args)

{

string dummyText=string.Empty;

for (int n=0; n < /*80*/ 3277; n++) // change this to
80 to get the second error above

{

dummyText += "0123456789";

}

// TO DO: Change data source to match your SQL Server:

SqlConnection con= new SqlConnection("data
source=myserver;Initial Catalog=mydb;Integrated Security=SSPI;persist
security info=True;packet size=16384");

SqlCommand cmd = new SqlCommand("SpParameterBug", con);

// Correct invocation:

SqlParameter param =new SqlParameter("@.myText",
SqlDbType.Text);

param.Value = dummyText;

cmd.CommandType = CommandType.StoredProcedure;

cmd.Parameters.Add(param);

con.Open();

try

{

cmd.ExecuteNonQuery();

}

catch (Exception err)

{

Console.WriteLine(err.ToString());

}

// Causes error 17805:

SqlParameter param2 =new SqlParameter("@.myText",
dummyText);

cmd.CommandType = CommandType.StoredProcedure;

cmd.Parameters.Add(param2);

try

{

cmd.ExecuteNonQuery();

}

catch (Exception err)

{

Console.WriteLine(err.ToString());

}

Console.ReadLine();

}

RESOLUTION

==========

To resolve these errors, make sure that you do the following:

1. Do not use SqlClient classes in a Finalize method or a C# destructor.

2. Specify the SqlDbType for the SqlParameter so that there is no inferred
type.

3. Specify a parameter size that is within the allowable limits of the data
type.

REFERENCES

==========

For more information about the maximum size for different data types, see
these sections of SQL Books Online:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_
na-nop_9msy.asp: nchar and nvarchar

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_
da-db_7msw.asp: Data Types

Shawn Aebi
Microsoft
This posting is provided "AS IS" with no warranties, and confers no rights.|||Actually here is a link to the thread...
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=IsYbP1AdDHA.2408%40cpmsftngxa06.phx.gbl&rnum=1&prev=/groups%3Fq%3Dsql%2Bserver%2B17805%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26scoring%3Dd%26selm%3DIsYbP1AdDHA.2408%2540cpmsftngxa06.phx.gbl%26rnum%3D1|||i faced the same error, but found that i was executing "return" in the middle of the transaction and thus the bug was fixed by completing the transaction.

A severe error occurred on the current command.

I am having problems with an error that I keep receiving. The error message states "A severe error occurred on the current command. The results, if any, should be discarded."

This error is popping up when I try to call a specific stored procedure in SQL2005. The error is not specific to ASP.NET code because it also occurs if I try to run the procedure in SQL Server Management Studio. The procedure is exactly the same that is running on an SQL2000 server on a live site, so it apparently is specific to SQL2005.

I have not worked much with SQL2005 or SQL cursors in the past and this code was not written by me so I am not sure where to start making changes, if any are needed.

The procedure is as follows:

ALTER PROCEDURE [dbo].[spGetAdmins]
@.userid int,
@.forDate datetime
AS

DECLARE @.lngTabCount INTEGER,
@.lngLoopCount INTEGER,
@.type varchar(15),
@.id varchar(20),
@.statement varchar(1000),
@.useridLocal int,
@.forDateLocal datetime

SET @.useridLocal = @.userid
SET @.forDateLocal = @.forDate

DECLARE @.AdminInfo TABLE (AdminID varchar(20), AdminName varchar(50))

/* check parameters */
IF (@.useridLocal <= 0)
BEGIN
RAISERROR( 'Invalid UserID (%d)', 16, 1, @.useridLocal )
END
IF (@.forDateLocal IS NULL)
BEGIN
SELECT @.forDateLocal = GETDATE()
END

DECLARE profInfo CURSOR
LOCAL FORWARD_ONLY
FOR
SELECT ProfileType, ProfileValue
FROM tblCSUserProfile
WHERE UserID = @.useridLocal and
(StartDate is not null or StartDate <= @.forDateLocal ) and
(EndDate is null or EndDate > @.forDateLocal )
ORDER BY ProfileType

OPEN profInfo
FETCH profInfo
INTO @.type, @.id

WHILE @.@.Fetch_Status = 0
BEGIN
IF @.id = '*'
BEGIN
INSERT INTO @.AdminInfo
VALUES ('*', '* Everything')
END
ELSE
BEGIN
INSERT INTO @.AdminInfo
SELECT adm.[ADM_CODE], adm.[ADMIN_NAM]
FROM OPENROWSET('SQLOLEDB', 'server'; 'database'; 'password', [table]) AS adm
WHERE adm.[ADM_CODE] = @.id
END

FETCH profInfo INTO @.type, @.id

END

CLOSE profInfo

DEALLOCATE profInfo

SELECT DISTINCT(UPPER(AdminID)) AS AdminCode
FROM @.AdminInfo
GROUP BY AdminID
ORDER BY AdminCode

(1) I would change the line

FETCH profInfo
INTO @.type, @.id

to

FETCH NEXT FROM profInfo INTO @.type, @.id

and


FETCH profInfo INTO @.type, @.id

to

FETCH NEXT FROM profInfo INTO @.type, @.id

I would also recommend using a table variable instead of cursors.

(2) Check out the syntax for OPENROWSET in BOL.

Try using the SQLNCLI (SQL Native Client) instead of SQLOLEDB and see if it makes a difference.

 

A severe error occurred on the current command.

When ever I run a particular report. Even if I set the
connection to don't time out. I keep getting this:
An error has occurred during report processing.
(rsProcessingAborted) Get Online Help Cannot read the next
data row for the data set MOPhoneSkins.
(rsErrorReadingNextDataRow) Get Online Help
A severe error occurred on the current command. The
results, if any, should be discarded.
I don't understand what's going on. Please help me out if
you've had this problem.
Thanks in advance,
BryanThis exception comes from the ADO.NET / the underlying data provider.
Reporting Services just wraps the exception.
There are many possible reasons why this exception can happen. One example:
you specify a stored procedure on server A in your report as data source. At
runtime this stored procedure tries to invoke another stored procedure on
server B through the linked server feature and fails because of missing
privileges to execute stored procedures on server B.
You might want to search ADO related newsgroups (e.g.
news:microsoft.public.dotnet.framework.adonet) or on the internet for the
exception message string "A severe error occurred on the current command.
The results, if any, should be discarded."
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"bmurtha" <anonymous@.discussions.microsoft.com> wrote in message
news:635a01c4826b$677f3d00$a501280a@.phx.gbl...
> When ever I run a particular report. Even if I set the
> connection to don't time out. I keep getting this:
> An error has occurred during report processing.
> (rsProcessingAborted) Get Online Help Cannot read the next
> data row for the data set MOPhoneSkins.
> (rsErrorReadingNextDataRow) Get Online Help
> A severe error occurred on the current command. The
> results, if any, should be discarded.
> I don't understand what's going on. Please help me out if
> you've had this problem.
> Thanks in advance,
> Bryan

A severe error occurred on the current command

Dear fellow sufferers...
I get the error noticed in the subjectline, while trying to put a 150MB
ZipFile into a SQL-2000-SP4-DB. This is the way I do it:
'***************************************
************************************
***********************
Public Function CYCLE__GisData_ZIP_Add(ByRef lCycleID As Long, _
ByVal sZipFile As String, _
ByRef sRetErrMsg As String) As Boolean
' Local Variables
Dim bError As Boolean
Dim sRetErrMsgSub As String
Dim fiZipFile As IO.FileInfo
Dim sSQL As String
Dim lFileLength As Long
Dim fileStream As IO.FileStream
Dim binReader As IO.BinaryReader
Dim binaryData() As Byte
Dim cmdSQL As SqlCommand
Dim paraSQL As SqlParameter
'-> reset return value
CYCLE__GisData_ZIP_Add = False
bError = False
sRetErrMsg = "Function: " & mc_sClassName & ".CYCLE__GisData_ZIP_Add"
Try
fiZipFile = New IO.FileInfo(sZipFile)
'-> save to Stream
fileStream = fiZipFile.OpenRead
binReader = New IO.BinaryReader(fileStream)
binaryData = binReader.ReadBytes(fileStream.Length)
lFileLength = fileStream.Length
binReader.Close()
fileStream.Close()
sSQL = "UPDATE tab_Cycle " + _
"SET GIS_Data = @.GIS_Data " + _
"WHERE (id = " & lCycleID & ")"
cmdSQL = New SqlCommand(sSQL, m_con_eRM_RFC)
paraSQL = New SqlParameter("@.GIS_Data", SqlDbType.Image)
paraSQL.Direction = ParameterDirection.Input
paraSQL.Value = binaryData
cmdSQL.Parameters.Add(paraSQL)
cmdSQL.ExecuteNonQuery()
Catch ex As System.Data.SqlClient.SqlException
Dim strSQLErr As String
Dim sqlErr As SqlError
For Each sqlErr In ex.Errors
strSQLErr = strSQLErr & sqlErr.ToString & vbNewLine
Next sqlErr
Throw New Exception(strSQLErr)
Catch ex As Exception
Throw New Exception(sRetErrMsg & sRetErrMsgSub & vbCrLf &
ex.ToString & vbCrLf)
Finally
'-> set return value
CYCLE__GisData_ZIP_Add = Not bError
End Try
End Function
'***************************************
************************************
***********************
All objects used are filled and the error occures on the
cmdSQL.ExecuteNonQuery(). There is no SQL-Errornumber or something like
that...
Any ideas or hints are welcome!
Cheers,
ChristophFor large binary streams, use a chunking method rather than sending the
entire value at once. See MSKB 317043
<http://support.microsoft.com/defaul...kb;en-us;317043> for an
examples.
Hope this helps.
Dan Guzman
SQL Server MVP
"Cheffe" <Cheffe@.discussions.microsoft.com> wrote in message
news:054F78D7-C8E9-405E-A67B-BB856074E090@.microsoft.com...
> Dear fellow sufferers...
> I get the error noticed in the subjectline, while trying to put a 150MB
> ZipFile into a SQL-2000-SP4-DB. This is the way I do it:
> '***************************************
**********************************
*************************
> Public Function CYCLE__GisData_ZIP_Add(ByRef lCycleID As Long, _
> ByVal sZipFile As String, _
> ByRef sRetErrMsg As String) As Boolean
> ' Local Variables
> Dim bError As Boolean
> Dim sRetErrMsgSub As String
> Dim fiZipFile As IO.FileInfo
> Dim sSQL As String
> Dim lFileLength As Long
> Dim fileStream As IO.FileStream
> Dim binReader As IO.BinaryReader
> Dim binaryData() As Byte
> Dim cmdSQL As SqlCommand
> Dim paraSQL As SqlParameter
>
> '-> reset return value
> CYCLE__GisData_ZIP_Add = False
> bError = False
> sRetErrMsg = "Function: " & mc_sClassName &
> ".CYCLE__GisData_ZIP_Add"
> Try
> fiZipFile = New IO.FileInfo(sZipFile)
> '-> save to Stream
> fileStream = fiZipFile.OpenRead
> binReader = New IO.BinaryReader(fileStream)
> binaryData = binReader.ReadBytes(fileStream.Length)
> lFileLength = fileStream.Length
> binReader.Close()
> fileStream.Close()
> sSQL = "UPDATE tab_Cycle " + _
> "SET GIS_Data = @.GIS_Data " + _
> "WHERE (id = " & lCycleID & ")"
> cmdSQL = New SqlCommand(sSQL, m_con_eRM_RFC)
> paraSQL = New SqlParameter("@.GIS_Data", SqlDbType.Image)
> paraSQL.Direction = ParameterDirection.Input
> paraSQL.Value = binaryData
> cmdSQL.Parameters.Add(paraSQL)
> cmdSQL.ExecuteNonQuery()
>
> Catch ex As System.Data.SqlClient.SqlException
> Dim strSQLErr As String
> Dim sqlErr As SqlError
> For Each sqlErr In ex.Errors
> strSQLErr = strSQLErr & sqlErr.ToString & vbNewLine
> Next sqlErr
> Throw New Exception(strSQLErr)
> Catch ex As Exception
> Throw New Exception(sRetErrMsg & sRetErrMsgSub & vbCrLf &
> ex.ToString & vbCrLf)
> Finally
> '-> set return value
> CYCLE__GisData_ZIP_Add = Not bError
> End Try
> End Function
> '***************************************
**********************************
*************************
> All objects used are filled and the error occures on the
> cmdSQL.ExecuteNonQuery(). There is no SQL-Errornumber or something like
> that...
> Any ideas or hints are welcome!
> Cheers,
> Christoph
>

A severe error occurred on the current command

I get this weird error. Was wondering whether anyone could help here with fi
nding a solution.
SqlException: A severe error occurred on the current command. The results,
if any, should be discarded.
I'm using 2 SQL 2000 Servers. Server A and Server B. I have a Stored
Procedure on Server A that executes a Stored Procedure on Server B. What's o
dd is that i can run the Stored Procedure on Server A in Query Analyzer and
it works
great... as expected... but when i call it in ASP.NET (VB.NET), i get the se
vere error
message.
Can you help me here with what is causing this and how can I get over with t
his error.
Thanks
Reji
****************************************
******************************
Sent via Fuzzy Software @. http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET
resources...Reji,
That error is being produced by ADO.NET, not by SQL Server. It's a
SqlException... Have you tried debugging your call to the stored procedure?
You might want to post this question in an ADO.NET specific group, or
perhaps microsoft.public.dotnet.languages.vb.data would be more helpful.
"Reji" <am_saved@.yahoo.com> wrote in message
news:%23wkbf%23BaEHA.3888@.TK2MSFTNGP10.phx.gbl...
> I get this weird error. Was wondering whether anyone could help here with
finding a solution.
> SqlException: A severe error occurred on the current command. The results,
> if any, should be discarded.
> I'm using 2 SQL 2000 Servers. Server A and Server B. I have a Stored
> Procedure on Server A that executes a Stored Procedure on Server B. What's
odd is that i can run the Stored Procedure on Server A in Query Analyzer and
it works
> great... as expected... but when i call it in ASP.NET (VB.NET), i get the
severe error
> message.
> Can you help me here with what is causing this and how can I get over with
this error.
> Thanks
> Reji
>
> ****************************************
******************************
> Sent via Fuzzy Software @. http://www.fuzzysoftware.com/
> Comprehensive, categorised, searchable collection of links to ASP &
ASP.NET resources...|||Thanks much Adam. Appreciate the help. Have posted the same in the forum you
said. Hope some one would answer me.
****************************************
******************************
Sent via Fuzzy Software @. http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET
resources...|||See whether this KBA http://support.microsoft.com/defaul...;82736
6 is any help to resolve.
--
--
Satya SKJ
"Adam Machanic" wrote:

> Reji,
> That error is being produced by ADO.NET, not by SQL Server. It's a
> SqlException... Have you tried debugging your call to the stored procedure
?
> You might want to post this question in an ADO.NET specific group, or
> perhaps microsoft.public.dotnet.languages.vb.data would be more helpful.
>
> "Reji" <am_saved@.yahoo.com> wrote in message
> news:%23wkbf%23BaEHA.3888@.TK2MSFTNGP10.phx.gbl...
> finding a solution.
> odd is that i can run the Stored Procedure on Server A in Query Analyzer a
nd
> it works
> severe error
> this error.
> ASP.NET resources...
>
>

Friday, February 24, 2012

a question about Exec

Hi,

When I run the following command on sql server:

exec ('print "OK"')
go

This message appears:

Server: Msg 128, Level 15, State 1, Line 1
The name 'OK' is not permitted in this context. Only constants,
expressions, or variables allowed here. Column names are not permitted.

Why? Thanks.findu_2005@.yahoo.com (findu_2005@.yahoo.com) writes:

Quote:

Originally Posted by

When I run the following command on sql server:
>
exec ('print "OK"')
go
>
This message appears:
>
Server: Msg 128, Level 15, State 1, Line 1
The name 'OK' is not permitted in this context. Only constants,
expressions, or variables allowed here. Column names are not permitted.
>
Why? Thanks.


Because when the setting QUOTED_IDENTIFIER is in effect, "" delmits
identifier. This permits you to use table names like Order Details, for
instance:

SELECT ... FROM "Order Details"

In the SQL Server world, we tend to use [] for this function, but "" is
what ANSI mandates.

QUOTED_IDENTIFIER is on by default in most contexts, but not when you
run from SQLCMD, OSQL or Enterprise Manager in SQL 2000. Or for that
matter all DB-Library applications.

When the setting is off, SQL Server reverts to the original behaviour
from 4.x days when you couls use both '' and "" to delimit strings.

--
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|||Something like this will work

exec ('print ''OK''') . *Note: all are single quotes.

or you'll have to use SET QUOTED_IDENTIFIER OFF and then execute the
SQL.

Regards,
Thyagu.

A query sentence return a puzzle result

the talbe row like this:

ID Name Scoe
11 Tome 20
12 Jack 30
11 Tome 40
12 Jack 10
13 John 10

My query command like this:

Select T1.Id,T1.Name,T2.math
from st T1
right join
(Select Id as Id2,Sum(Math) as Math from St group by id) T2
on T1.id=t2.id2
where t1.id = t2.id2

While the reuslt is :

Id Name Score

11 Tom 60

11 Tom 60

12 Jake 40

12 Jack 40

13 John 10

I am wonder :the T1 gives a table with six rows, the T2 gives a table with three rows, and I use RIGHT JOIN to connect the two table,the result should be a table with only three rows.I tried INNER JOIN, the result is same.

but why ? please help me !


This might be what you want?
select ID, Name, Sum(Score) as Math from St group by ID, Name

result;

ID Name Math ---- ---------------- ---- 12 Jack 4013 John 1011 Tome 60(3 row(s) affected)

Thursday, February 16, 2012

A Probelm with sqlConnection Command ....

I have met a problem in the ASP.NET project creation with SQL Server Database Connection.

"Can't Login to My ServerName/ASPNET

How to solve the problem?

You need to give the ASPNET account a login and permissions to your database in SQL Server.

Thursday, February 9, 2012

a few easy noob questions about tables

i have made a table. but i want to add more columns to it. which command do i use? UPDATE? :o
what is joining tables? I need to make a table which contains the list of the states in US, and then somehow each state needs to link to its own unique table. :eek:It would help us do your homework if we actually had a copy of it. Do you have a URL for a web site where we can view it online, or a copy that you can post for us to download?

-PatP|||if u wanna add column, the easiest way is just using table design in Enterprise manager. if wanna use script, see the sql server books online for
alter table :
ALTER TABLE <table name> ADD <column definition>
column definition would be the column name, type, default value, constraint, ...|||Ouch Pat that was mean!

(I wait to see if it was justified though.)|||Ouch Pat that was mean!
(I wait to see if it was justified though.)
Not at all, it is better to motivate a noob to do some research on his own and actually read (http://www.jargon.net/jargonfile/r/RTFM.html) the manuals (http://www.oracle.com/pls/db92/db92.homepage). :D|||ya i just finished reading some tutorials online.

so i have several tables...bare with me

-North_America

-Nord_Province (holds names of both candian provinces and american states)

-British_Columbia to Wyoming (each table named after the state, and holds names of stadiums in that state/province...so about 70 tables )

This what i've done:

alter table North_America
add column country_id not null primary key auto_increment;

and i saw when i select*from North America

the display shows that Canada with country_id "1" and United States with country_id "2".

then i made a second table which includes both all the province of Canada and states of America. nord_province
(canadian province first and american states following alphabetically after the last canadian province. ex British Columbia....Newfoundland, Arizona, Alabama...etc)

Now I have to indicate id "1" to all Candian province and id "2" to all American states. i didn't add auto_increment (since i only need two numbers 1 & 2), and it won't let me do this. I made another column state_id which is a primary key not null auto_increment.

here's a table of what im trying to achieve. state_id i was easily able to do. the problem is creating a non auto incrementating id.

|name VARCHAR(40) | id INT | state_id |

|British Columbia | 1 | 1 |
|Alberta | 1 | 2 |
|Sasktchewan | 1 | 3 |
|.... | 1 | 4 |
|... | 1 | 5 |
|... | 1 | 6 |
|Arizona | 2 | 7 |
|Alabama | 2 | 8 |

something like this... but do i still use PRIMARY KEY for this? because my id is not unique for all individual province and states. i read on this...but still confused...the books weren't too clear.

Ok, finally i have basically another table holding extensive data of all the stadium names for each state and province.

so i would probably have about 70 different tables for each province or state with state_id and stadium names in that region.

so for british columbia...i would have something like this.

|stadium_name VARCHAR(40) | state_id |

|GM place | 1 |
|XXX stadium | 1 |
|bal bal stadium | 1 |
|XYXY stadium | 1 |
|... | 1 |
|... | 1 |

and for alberta...i would have similiar columns but all state_id have "2" and the next province with state_id with "3" for all.

whew...well this is the best i can put it as...help would be greatly appreciated. basically im looking for a way to make a column for key in without auto incrementation... or any other way is good too.|||i have made a table. but i want to add more columns to it. which command do i use? UPDATE?No; with UPDATE, INSERT and DELETE you change the contents of the table, not the structure.
If your database system allows it, you may add columns with the "ALTER TABLE" SQL statement:ALTER TYPE mytable ADD column_name DATA_TYPE