Showing posts with label working. Show all posts
Showing posts with label working. Show all posts

Friday, March 30, 2012

Problem returning two values from stored procedures

Hi, i am trying to return two values from SQL 2000 using a single stored procedure. The stored working fine in Query Analyser and returns the two values and two grids in the results window.

My problem is that when i execute the stored procedure using ADO.Net the dataset only has one of the values. e.g TId : 2, where it should read 'TId' : 2, 'ConfigPath': 'C:\blah'

Please could anyone shed ligth on this problem?

here the code for the stored procedure:

CREATE PROCEDURE dbo.GetTillInfo
(
@.TillIdR varchar(50),
@.Password varchar(50)
)
AS

declare @.TillId int
declare @.configpath varchar(150)

IF Exists (SELECT Id FROM Tills WHERE TillRef=@.TillId and TillPassword=@.Password)
BEGIN

set @.TillIdR = (SELECT Id FROM Tills WHERE TillRef=@.TillId and TillPassword=@.Password)
select @.TillIdR as 'TId'

set @.configpath = (SELECT configpath from customer,tills where
tills.customerid = customer.id and tills.id = @.login)
select @.configpath as 'ConfigPath'
END
ELSE
BEGIN
set @.TillIdR = 0
select @.TillIdR as 'TId'
set @.configpath =''
select @.configpath as 'ConfigPath'
END
GOOff the top of my head, the two results may be returned but in two tables as you are performing two selects.

To get round this you could change your select query to return the two values like:-


IF ...
set @.TillIdR = (SELECT Id FROM Tills WHERE TillRef=@.TillId and TillPassword=@.Password)
set @.configpath = (SELECT configpath from customer,tills where
tills.customerid = customer.id and tills.id = @.login)

select @.TillIdR as 'TId', @.configpath as 'ConfigPath'
END
ELSE
BEGIN
set @.TillIdR = 0
set @.configpath =''
select @.TillIdR as 'TId', @.configpath as 'ConfigPath'
END
GO

This is off the top of my head at work - you may have to play with the stored proc.

Rob

Monday, March 26, 2012

PROBLEM REGARDING VARIABLE PASSING TO STORED PROCEDURE

Hi

I am WORKING IN AN APPLICATION USING SQL SERVER 2000 AND VB6

I'VE A PROBLEM REGARDING VARIABLE PASSING TO STORED PROCEDURE

I WILL EXPLAIN WITH AN EXAMPLE

TABLE STRUCTURE

AccAccounts

Accid(Numeric) AccName(Varchar)

-

1 Cash A/c

2 Students A/c

3 HDFC Bank A/c

my Application will pass the "Accid" as a string format to Stored Procedure

STORED PROCEDURE

--

CREATE PROCEDURE GetAccName
@.Accid Varchar(100)
AS
Select * from Accaccount where accid in (@.Accid)

when i run this SP

declare @.Accid Varchar(100)
set @.Accid ='1,2'

exec GetAccName @.Accid

i get the following error

Server: Msg 8114, Level 16, State 5, Procedure GetAccName, Line 4
Error converting data type varchar to numeric.

please "ANY ONE" help me!!.

The above example is only an example

REGARDS

JAMES

Hi,

You can not use the @.Variable which holds the multiple accountids in Static SQL statement.. you need to use dynamic sql..

Code Snippet

CREATE PROCEDURE GetAccName
@.Accid Varchar(100)
AS
Declare @.cmd varchar(4000)

Set @.Cmd = 'Select * from Accaccount where accid in (' + @.Accid')'

exec (@.cmd)

But would suggest you to go through the following link to see the advantages and disadvantages..

http://www.sommarskog.se/dynamic_sql.html

Regards,

|||

You can also do this without dynamic sql.

Code Snippet

CREATE PROCEDURE GetAccName
@.Accid Varchar(100)
AS
Select *
from AccAccounts
where charindex(','+convert(varchar,accid)+',',','+@.Accid+',')>0

|||

THANK U VERY MUCH

|||

Hi James

You shouldn't pass comma separated values to the stored procedure, like: '1,2,3' . Because when you call the sproc it is trying to convert your value(because accid is numeric in your table) to varchar implicitly and due to the ',' in your data the conversion is going to fail and throws an error. You need to write some other logic to get it done.

Thanks & Regards,

Kiran.Y

|||

HI

THX FOR REPLY

WHAT IN CASE IF I NEED A QRY

Select * from AccAccounts where Accid Not in (1,2)

|||

>0 means a match is found

=0 means no match.

Code Snippet

CREATE PROCEDURE GetAccName
@.Accid Varchar(100)
AS
Select *
from AccAccounts
where charindex(','+convert(varchar,accid)+',',','+@.Accid+',') = 0

|||

Thx

Wednesday, March 21, 2012

Problem passing parameter from VB.Net 2005 to crystal - code included

I am trying to pass a few parameters to crystal from vb.net 2005. Here is what I have, and it is not working. Everything else on the report works fine. Any ideas?

It is asking me to enter the value in a new window when the report loads..."You can provide a single value for this parameter. Enter the value you want to include........."

Dim strReportPath1 As String = "MainSummary"
Dim strConnection As String = "Data Source=localhost;Integrated Security=SSPI;" & _
"Initial Catalog=Carc2;"
Dim Connection As New SqlConnection(strConnection)
Dim strSQL As String = "My Select statement is here...too long to show in code"
Dim DA As New SqlDataAdapter(strSQL, Connection)
Dim DS As New DataSet

DA.Fill(DS, "SummaryInfo")

Dim strReportPath As String = Application.StartupPath & "\" & strReportPath1 & ".rpt"

If Not IO.File.Exists(strReportPath) Then
Throw (New Exception("Unable to locate report file:" & vbCrLf & strReportPath))
End If

If frmSummaryRpt.RadioShip.Checked = True Then
cr.SetParameterValue("ShipDate", frmSummaryRpt.txtStart.Text & " - " & frmSummaryRpt.txtEnd.Text)
ElseIf frmSummaryRpt.RadioShip.Checked = False Then
cr.SetParameterValue("ShipDate", "No ShipDate Selected")
End If

cr.Load(strReportPath)
cr.SetDataSource(DS.Tables("SummaryInfo"))This is resolved. The problem was that my if statements were before the report was loaded. I moved the area that they occured and it worked finesql

Tuesday, March 20, 2012

Problem on parallelism

after running query at first time working all processes

but later 2-3 sec. working only one

SQL 2005

Hewlett Packard DL580 (16 processes)

What is ideas?

Hi Vladmir,

Could you please expand on what you are trying to do and what you are experiencing?

thanks

Jag

|||It's possible that you're seeing the initial disk reads for the query being done in parallel, and then the remainder of the execution carrying on in a single thread, but that's about the best guess I can give from the current information. Not all queries will be executed in multiple parallel threads - there are certain criteria and requirements used by the query optimizer to decide on a degree of parallelism.|||

Thanks for replies!

I have a bank's system (Diasoft 5NT)

It works with SQL Server 2005 (64 bit version). If I run stored procedure in QA - OK! All processes work.

It executing on multiple EC (executing context)

But if I run in programm (Diasoft 5NT) - after few second work only one thread.

P.S. Connect to database over BDE (Borland Database Engine).

|||

davidbrit2 wrote:

It's possible that you're seeing the initial disk reads for the query being done in parallel, and then the remainder of the execution carrying on in a single thread, but that's about the best guess I can give from the current information. Not all queries will be executed in multiple parallel threads - there are certain criteria and requirements used by the query optimizer to decide on a degree of parallelism.

Yes! I think.

But the same query in one case are executing in multiple parallel threads , in other case in single.

|||

Thanks for all!

This problem have been resolved when I turn on "Auto Create Statistic" and "Auto Update Statistic"!

This option had been turned off because we planning run update statistic at night time.

Monday, March 12, 2012

Problem of SQL Server 2005 Reporting service installation

The report manager site not working properly after I install the SQL Server 2005. I have been tried to fix it since yesterday. But it just getting worse. I need to get this to work properly before I can install the Visual Studio Team Foundation Server.

I am following the Visual Studio Team Foundation Installation Guide.
The Steps I have done so far are:

1. Install SQL Server 2005 and assign application pool to reports and report server sites in IIS.

2. Try to install Team Foundation Server, but I noticed that it requires sharepoint service to be installed first. The service seems already installed in this computer. So I didn't reinstall the sharepoint service. When I try to exclude the SQL Server Reporting Services Web applications from share point service, the command throw exceptions. When I try to view the localhost/reports, the page has errors(Reports server Unable to generate a temporary class, CS2001: xxx.dll could not be found error CS2008: No inputs specified). xxx.dll refers to different dlls each time I request the page.

3. Uninstall Sharepoint and reinstall, still encounter the same problem.

4. Uninstall SQL Server 2005, I also noticed the ReportServer sites in IIS haven't been removed after uninstallation. So when I reinstall the SQL Server again, on the Report Server Installation Options page, I can't select Install the default configuration (default selection), instead the second option is selected which is no auto configuration(options are all grey out so I can't change the selection). After installation, the report server site get a no page found error.

I also noticed in IIS - Report Server(Stop) can't be start. I get a Parameter is incorrect error when I try to restart. There is two sites underIIS - Report Server(Stop) , they are Reports and ReportServer, they seems correct. But if right click the Report Server(Stop) and click Properties - Asp.NET tab. It point to the D:\Program Files\Microsoft SQL Server\InetPub\wwwroot\web.config. However, I can't find any web.config under Microsoft SQL Server\InetPub\wwwroot\. So it seems something missing there...

Please help... Any idea and suggestion are welcome!
There are a lot of pieces at work here. For some reason, SharePoint doesn't seem to be too happy. We are working on making the RS and SP combination setup experience better but this won't be until RTM. Here is what I would do:

1. Uninstall SQL Server (and RS). Delete the virtual directories in IIS and the SQL directories in the file system (including the databases)
2. Uninstall the .NET Framework 2.0 (this shouldn't be the reason, but just to be safe)
3. Reinstall SharePoint. Make sure that it is working, including the ability to exclude virtual directories.
4. Install RS. You might have to go with a 'non-default' install and use the RS Configuration tool to create the virtual directories. They will need to be in a different application pool than SharePoint. If the default install works, you will need to change the application pool for the vdirs created by setup.
5. Exclude the RS virtual directories in the SP Site Configuration.|||Thank you for your detailed information. One more question, I installed Active Directory after installed the IIS. In your case, did you install IIS after you install AD or before? I just wonder whether I should reinstall IIS.

Cheers|||Thank you very much, I uninstall IIS and sharepoint and reinstall them, everything works fine so I eventually can begin install the Foundation server, but when I install the server, I get 32000 error.
Error 32000. The Commandline "D:\ProgramFiles\Microsoft Visual Studio 2005 Enterprise Server\BISIISDIR\sdk\bin\tfsadaminst.exe" /install DIONYSUS 2420 TFGSS Hyperknowledge\TFSSETUP' return non-zero value:1

I have a look the event viewer and these errors are all cannot create *** performance counter, for example:

The report server cannot create the Cache Misses/Sec (Semantic Models) performance counter.

I wonder wether the memory is not enough in the machine...

Saturday, February 25, 2012

Problem Installing RS

I have a windows 2000 Ent. test server with IIS, SQL 2K Ent., ASP.NET
running. Today after I installed RS Std. version the ASP.NET stopped
working with a permission error. I chose not to install Report Designer and
asked because Visual Studio .NET isn't installed. Removing RS fixed will
fix the ASP.NET problem. I really lost here. On my XP box I tested with
SQL and RS worked fine. Don't know what's wrong here. Can you guys help?
Thx.it was a bug described in http://support.microsoft.com/kb/887787
"ME" <ME@.hotmail.com> wrote in message
news:%23zKPpsOVFHA.3184@.TK2MSFTNGP15.phx.gbl...
>I have a windows 2000 Ent. test server with IIS, SQL 2K Ent., ASP.NET
>running. Today after I installed RS Std. version the ASP.NET stopped
>working with a permission error. I chose not to install Report Designer
>and asked because Visual Studio .NET isn't installed. Removing RS fixed
>will fix the ASP.NET problem. I really lost here. On my XP box I tested
>with SQL and RS worked fine. Don't know what's wrong here. Can you guys
>help? Thx.
>

Monday, February 20, 2012

Problem inserting into a Text field in a temp table after SP3

I have a stored proc that is inserting data into a Text field. This was
working fine on Friday, but today throws the following error:
ODBC: Msg 0, Level 19, State 1
SqlDumpExceptionHandler: Process 55 generated fatal exception c0000005
EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.
Yesterday we upgraded our SQL server from SP2 to SP3, and today we upgraded
3 to 3a after finding this problem. We found the KB article 817359 which
seems to be related, but if we change their example from nText & nVarchar to
Text and Varchar we still get the error (the same one as above). Can anyone
tell me how to fix this problem?
TIA
Ron LounsburyRon,
You should contact PSS to report this. An AV normally means a bug in
sqlserver. You should not be charged for this incident.
--
-oj
RAC v2.2 & QALite!
http://www.rac4sql.net
"Ron Lounsbury" <rlounsbury AT Progeny DOT net> wrote in message
news:uwvRfPrsDHA.1788@.tk2msftngp13.phx.gbl...
> I have a stored proc that is inserting data into a Text field. This was
> working fine on Friday, but today throws the following error:
> ODBC: Msg 0, Level 19, State 1
> SqlDumpExceptionHandler: Process 55 generated fatal exception c0000005
> EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.
> Yesterday we upgraded our SQL server from SP2 to SP3, and today we
upgraded
> 3 to 3a after finding this problem. We found the KB article 817359 which
> seems to be related, but if we change their example from nText & nVarchar
to
> Text and Varchar we still get the error (the same one as above). Can
anyone
> tell me how to fix this problem?
> TIA
> Ron Lounsbury
>|||OJ
Thanks for the response. It was a bug that they have a fix for, but you
have to call them to get it.
Ron Lounsbury
"oj" <nospam_ojngo@.home.com> wrote in message
news:eJjF$jrsDHA.4056@.TK2MSFTNGP11.phx.gbl...
> Ron,
> You should contact PSS to report this. An AV normally means a bug in
> sqlserver. You should not be charged for this incident.
> --
> -oj
> RAC v2.2 & QALite!
> http://www.rac4sql.net
>
> "Ron Lounsbury" <rlounsbury AT Progeny DOT net> wrote in message
> news:uwvRfPrsDHA.1788@.tk2msftngp13.phx.gbl...
> > I have a stored proc that is inserting data into a Text field. This was
> > working fine on Friday, but today throws the following error:
> >
> > ODBC: Msg 0, Level 19, State 1
> > SqlDumpExceptionHandler: Process 55 generated fatal exception c0000005
> > EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.
> >
> > Yesterday we upgraded our SQL server from SP2 to SP3, and today we
> upgraded
> > 3 to 3a after finding this problem. We found the KB article 817359
which
> > seems to be related, but if we change their example from nText &
nVarchar
> to
> > Text and Varchar we still get the error (the same one as above). Can
> anyone
> > tell me how to fix this problem?
> >
> > TIA
> > Ron Lounsbury
> >
> >
>

Problem inserting data into remote server

Hello,

I'm working on an old database that has been converted to SQL server 2000 and I am having a problem executing the DML statement below. It looks like the problem is related to column file. File seems to be a reserved keyword for sql server. How do I get around this? I already tried brackets around the column name etc.

INSERT INTO [NW_Test_MM].[NW_35].[dbo].T_LOG_STORAGE ([source], [session_id],session_index, [header_type],
[app_type],
[access],
[start] ,
[stop],
[computer],
[file],
[insert_time])
SELECT [source], [session_id],
[session_index], [header_type],
[app_type],
[access],
[start] ,
[stop],
[computer],
[file],
[insert_time] FROM T_LOG_STORAGE WHERE NOT EXISTS ( SELECT session_id FROM [NW_Test_MM].[NW_35].[dbo].T_LOG_STORAGE derived WHERE T_LOG_STORAGE.source = derived.source AND T_LOG_STORAGE.session_id = derived.session_id AND T_LOG_STORAGE.session_index = derived.session_index) AND T_LOG_STORAGE.source = @.dSource

(1 row(s) affected)

Server: Msg 7399, Level 16, State 1, Line 1
OLE DB provider 'MSDASQL' reported an error.
[OLE/DB provider returned message: [Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not be prepared.]
[OLE/DB provider returned message: [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'file'.]
OLE DB error trace [OLE/DB Provider 'MSDASQL' IRowsetChange::InsertRow returned 0x80004005: ].Originally posted by hijinks
Hello,

I'm working on an old database that has been converted to SQL server 2000 and I am having a problem executing the DML statement below. It looks like the problem is related to column file. File seems to be a reserved keyword for sql server. How do I get around this? I already tried brackets around the column name etc.

INSERT INTO [NW_Test_MM].[NW_35].[dbo].T_LOG_STORAGE ([source], [session_id],session_index, [header_type],
[app_type],
[access],
[start] ,
[stop],
[computer],
[file],
[insert_time])
SELECT [source], [session_id],
[session_index], [header_type],
[app_type],
[access],
[start] ,
[stop],
[computer],
[file],
[insert_time] FROM T_LOG_STORAGE WHERE NOT EXISTS ( SELECT session_id FROM [NW_Test_MM].[NW_35].[dbo].T_LOG_STORAGE derived WHERE T_LOG_STORAGE.source = derived.source AND T_LOG_STORAGE.session_id = derived.session_id AND T_LOG_STORAGE.session_index = derived.session_index) AND T_LOG_STORAGE.source = @.dSource

(1 row(s) affected)

Server: Msg 7399, Level 16, State 1, Line 1
OLE DB provider 'MSDASQL' reported an error.
[OLE/DB provider returned message: [Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not be prepared.]
[OLE/DB provider returned message: [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'file'.]
OLE DB error trace [OLE/DB Provider 'MSDASQL' IRowsetChange::InsertRow returned 0x80004005: ].

What is it: (1 row(s) affected) - looks like insert was done? Do you have triggers on remote table?

Try to do simple insert and check is it work at all.|||Actually the (1 row(s) affected) is a by product of me printing the INSERT statement, so the insert does not happen.|||Actually the (1 row(s) affected) is a by product of me printing the INSERT statement, so the insert does not happen.

Problem inserting data in SQL express

Hello everybody

I'm working with a database and trying to add data to the database with the next stameny:

INSERT INTO table VALUES ('value1')

but the result of doing this, even with the Management studio, is the value value1 with one space at the end. It is like 'value1 '

Any clue?

Thank you very much and greetings from spain.

Santiago

Hi,

Most likely your field declared as CHAR(7), not VARCHAR(7). Length of your string is 6 characters and for the CHAR types SQL Server fills rest of the string with the spaces. This is by-design. If you need a value without spaces, then you would need to use VARCHAR type for this field

|||Thank you very much for the help, problem solved.