Showing posts with label written. Show all posts
Showing posts with label written. Show all posts

Monday, March 19, 2012

Add Temp Parameters to a function

I am writing a set of functions and then a stored procedure to allow me to view some data in Reporting Services. I have written the first part of the function as shown ;

set ANSI_NULLS ON

set QUOTED_IDENTIFIER ON

GO

ALTER FUNCTION [dbo].[fnWTRTerrierData]

(@.vch_site_ref nvarchar (3), @.dt_src_date datetime)

RETURNS @.WeeklyTerrierRSPI TABLE

(Areacode varchar(2),siteref nvarchar(3),

estatename nvarchar(100), Securitised nvarchar(255),

unitref nvarchar(15), unittype nvarchar(30),

unittype_count int, tenantname nvarchar(100),

tenantstatus nvarchar(25), tenantstatus_count int,

unitstatus nvarchar(15), unitstatus_count int,

floortotal float, floortotocc float,

initialvacarea float, initialvacnet float,

TotalRent float, NetRent float,

FinalRtLsincSC float, DiscEndDate datetime,

ErvTot float, Leaseterm int,

leasestart datetime, rentreview nvarchar(255),

leaseend datetime, breakclause datetime,

tenancyterm datetime, landact nvarchar(255),

datadate datetime)

AS

BEGIN

INSERT @.WeeklyTerrierRSPI

SELECT Areacode, siteref, estatename, Securitised, unitref, unittype, unittype_count, tenantname,

tenantstatus, tenantstatus_count, unitstatus, unitstatus_count, floortotal, floortotocc,

initialvacarea, initialvacnet, TotalRent, NetRent, FinalRtLsincSC, DiscEndDate, ErvTot,

Leaseterm, leasestart, rentreview, leaseend, breakclause, tenancyterm, landact, datadate

FROM dbo.src_terrier

WHERE (datadate = @.dt_src_date) AND (siteref = @.vch_site_ref)

RETURN

END

I have then written a stored procedure which picks up the result set from the function and ultimately will deliver it to Reporting Services. The problem I have is that as soon as I run the CREATE PROCEDURE script, I get an error saying ;

Msg 216, Level 16, State 1, Procedure spWTRWeeklyTerrierData, Line 16

Parameters were not supplied for the function 'fnWTRTerrierData'.

How can I add parameters to the function sufficently so that I can run the Create procedure element of my code?

Regards

Post your Stored Procedure codes.|||

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE PROCEDURE [dbo].[spWTRWeeklyTerrierData]

(@.vch_site_ref nvarchar(3), @.dt_src_date datetime)

AS

BEGIN

SET NOCOUNT ON;

SELECT fnWTRTerrierData.Areacode, fnWTRTerrierData.siteref, fnWTRTerrierData.estatename, fnWTRTerrierData.Securitised, fnWTRTerrierData.unitref, fnWTRTerrierData.unittype, fnWTRTerrierData.unittype_count, fnWTRTerrierData.tenantname,fnWTRTerrierData.tenantstatus, fnWTRTerrierData.tenantstatus_count, fnWTRTerrierData.unitstatus, fnWTRTerrierData.unitstatus_count, fnWTRTerrierData.floortotal, fnWTRTerrierData.floortotocc, fnWTRTerrierData.initialvacarea, fnWTRTerrierData.initialvacnet, fnWTRTerrierData.TotalRent, fnWTRTerrierData.NetRent, fnWTRTerrierData.FinalRtLsincSC, fnWTRTerrierData.ErvTot, fnWTRTerrierData.tenancyterm, fnWTRTerrierData.landact, fnWTRTerrierData.datadate

FROM fnWTRTerrierData

RETURN

END

|||

Looking at a stored procedure I pulled over from a SQL 2000 DB, I took out the elements that seems to resemble the function side

BEGIN

SET NOCOUNT ON;

RETURN

END

But I am still met with the same parameters message when I try to execute the SQL code to create the SP.

Regards

|||

ALTER FUNCTION [dbo].[fnWTRTerrierData]

(

@.vch_site_ref nvarchar (3),

@.dt_src_date datetime

)


Your table function is expecting 2 input parameter which you did not supply.
You will need to supply these 2 value to the function
for example

SELECT ...
FROM fnWTRTerrierData ('?', '2006-01-01')

Tuesday, March 6, 2012

add new record - weird results

I have written a generic script in asp to add records to a table. The
script works fine with one table but in the other tables it updates
the first record in the table with the values for the new record and
adds a new record with all null values?!? Here is the script:

adOpenKeyset=1
adLockOptimistic=3
Set cnnFormToDB = Server.CreateObject("ADODB.Recordset")
'INSERT******************************************* ******************
'Open connection to sub-table
if action = "insert" then
cnnFormToDB.Open "SELECT top 1 * FROM " &subtable,
"DSN=Barrheadsql;UID=barrhead;PWD=ty93eta",
adOpenKeyset,adLockOptimistic
cnnFormToDB.AddNew
else
cnnFormToDB.Open "SELECT top 1 * FROM " & subtable & " WHERE ID = " &
ID, "DSN=Barrheadsql;UID=barrhead;PWD=ty93eta", adOpenKeyset,
adLockOptimistic
End If

if not cnnFormToDB.eof then
cnnFormToDB.MoveFirst
end if
'DELETE******************************************* ********************
if action = "delete" then
cnnFormToDB.Delete
cnnFormToDB.Close
else
'Build 2nd SQL String
For i=0 To Ubound(aFields)
cnnFormToDB(aFields(i)) = aValues(i)
Next

'Insert record into sub-table
cnnFormToDB.Update

The even weirder thing is I know that values in aFields and aValues
are OK because this test script I wrote for one of the tables works
just fine:

adOpenKeyset=1
adLockOptimistic=3
Set cnnFormToDB = Server.CreateObject("ADODB.Recordset")
cnnFormToDB.Open "SELECT top 1 * FROM FlightsDirect",
"DSN=Barrheadsql;UID=barrhead;PWD=ty93eta", adOpenKeyset,
adLockOptimistic
cnnFormToDB.AddNew

cnnFormToDB("fkCity") = 198
cnnFormToDB("fkDepartureAirport") = 159
cnnFormToDB("ValidFrom") = "17/09/2003"
cnnFormToDB("ValidTo") = "15/10/2003"
cnnFormToDB("fkType") = 1
cnnFormToDB("ReturnFlight") = 1
cnnFormToDB("fkReturnAirport") = 184
cnnFormToDB("Price") = yyyyyy
cnnFormToDB("fkATOL") = 5346

cnnFormToDB.Update

Any suggestions appreciated

Thanks

AlisonButtercup (alison_clark20@.hotmail.com) writes:
> I have written a generic script in asp to add records to a table. The
> script works fine with one table but in the other tables it updates
> the first record in the table with the values for the new record and
> adds a new record with all null values?!? Here is the script:

I cannot really say what is going on. The problem with ADO is that
while it tries to hides to the SQL from you, it does actually makes
you more confused, because you don't know what is going on under the
covers.

You can use the Profiler to see what ADO submits to SQL Server.

However, rather than relying on ADO doing things right by chance, I
would encourage you to use stored procedures instead. Then you don't
use these .AddNew or .Update methods.

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

Thursday, February 16, 2012

add a reference in scriptComponent

I would like to use a custom build class library written in C# inside of the vb script. Does anyone know how to add the reference to the scriptComponent project once you open script through design script button?

By the way I am using visul studio 2005.

Thanks!

Jun,

You'll need to have your class assembly added to the GAC. Procedure here.

After that, you can add it by selecting the Project > Add Reference... in the opened script editor.

|||

That's not the only thing that you need to do. Read this:

VSA requires DLLs to be in the Microsoft.Net folder (but not all the time)

(http://blogs.conchango.com/jamiethomson/archive/2005/11/02/SSIS_3A00_-VSA-requires-DLLs-to-be-in-the-Microsoft.Net-folder-_2800_but-not-all-the-time_2900_.aspx)

-Jamie

|||It may also be valuable to point out that this same process can be used to call web services from script components/tasks as well (helpful for complete control over web service calls instead of using limited built in SSIS web service task). You can use wsdl.exe to create the proxy class then go through the same steps outlined above.|||

ADMariner wrote:

It may also be valuable to point out that this same process can be used to call web services from script components/tasks as well (helpful for complete control over web service calls instead of using limited built in SSIS web service task). You can use wsdl.exe to create the proxy class then go through the same steps outlined above.

And (in case anyone is still reading/interested Smile ) in Katmai you'll be able use Web References just as you can in Visual Studio today. So no need to even use WSDL.exe

-Jamie

|||Thanks a lot! I will try.|||

I installed my dll into GAC and also put it under .net directory. But when I add reference to my dll in ScriptCommponent project. Before adding any code , I could not save project anymore. It complained "Object reference not set to an instance of an object". Anyone know what I missing here?

Thanks!

|||

Jun Fan wrote:

I installed my dll into GAC and also put it under .net directory. But when I add reference to my dll in ScriptCommponent project. Before adding any code , I could not save project anymore. It complained "Object reference not set to an instance of an object". Anyone know what I missing here?

Thanks!

You don't actually have to save the project. Just closing down VSA will store all of the code within your script task/component.

Try just doing that and see if you still run into problems.

-Jamie

|||

Wow, it works without save project. I can't believe it. Thanks very very much!

I am new from java world to window world. Do you mind light me some more?

What I am trying to do is that taking input columns and using script to build a object that my webservice recogonized and serialized object and store serialized data to database. I used transformation type of scriptComponent, and added output column named serializedObject as Byte Stream type from ScriptComponent. In VB script serializedObject is byte[] , so I assign byte[] return from serializing object to it. But when I run intergation service I go error complain "The value is too large to fit in the column data area of the buffer."

Anybody have suggestion?

Thanks!

|||

Jun Fan wrote:

Wow, it works without save project. I can't believe it. Thanks very very much!

I am new from java world to window world. Do you mind light me some more?

What I am trying to do is that taking input columns and using script to build a object that my webservice recogonized and serialized object and store serialized data to database. I used transformation type of scriptComponent, and added output column named serializedObject as Byte Stream type from ScriptComponent. In VB script serializedObject is byte[] , so I assign byte[] return from serializing object to it. But when I run intergation service I go error complain "The value is too large to fit in the column data area of the buffer."

Anybody have suggestion?

Thanks!

The default length of the byte stream type (i.e. DT_BYTES) when you add a column of that type to the script component is 50. My guess is that the length of the value you are tryig to put in there is more than 50.

-Jamie

Thursday, February 9, 2012

Actual risk of opening port 1433

Greetings.
I have written a nice little application suite used by 8 or so workstations,
some of which are connected through a VPN. The IT people claim that port
1433 is blocked by default by Nortel's Conntivity VPN, and they will not
make an attempt to change it for fear it will muck up the works elsewhere.
As the SQL server (actually, an instance of MSDE) lives on a dedicated
little WinXP Pro box which does nothing else, I recommended they open port
1433 on their router and point it to that box, allowing the offsites to
circumvent the VPN altogether. The IT director looked at me point blank and
stated that would mean anyone could come in and "hack" both their Win2k
Server, and their IBM Midrange running OS/400.
My question - while I understand the director's concern is completely
irrational... what ACTUAL issues can opening port 1433 to an isolated box
really raise? Even assuming that the intruder coud bypass the credentials (I
am using SQL Authentication, gods help me), what could they possibly do to
anything other than that one MSDE instance?
Many thanks in advance.
Hal Meyer, Proprietor
the patchwerks
(423) 462-2606
http://www.thepatchwerks.com1. SQL Authentication is very insecure.
2. The 'box' is not isolated. It is connected to the network inside the
firewall.
3. Every hacker in the world knows that port 1433 is a standard SQL port and
therefore a target.
4. MSDE runs with LocalSystem permissions. That may provide a platform to
hack the inside servers.
5. Any hacker worth his/her 'salt' will know every weakness of MSDE -and
there a quite a few.
6. The IT people are right!
7. The IT director was very kind in his response to you.
So, suck it up and move on. There is unlikely to be any legitimate business
case for such a 'foolhardy' move.
Your outside users access the internal network using a secure VPN. That
'should' provide them access to the MSDE instance while connected through
the VPN. I would check with the VPN vendor about any problems accessing SQL
Server (MSDE) through the VPN 'tunnel'.
In the rare circumstances where there is a business case to open firewall
port 1433, it usually mandates Rules restricting external IP addresses, more
advanced security (SSL, etc.), as well as constant vigilence and traffic
logging - as well as a rigorous process to attempt to gain approval.
Think about leaving the door key to your home under the 'Welcome' mat. Would
that be a wise action? Wouldn't most potential thieves look under the mat as
their first effort to gain entry.
Arnie Rowland
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
"Hal Meyer" <hmeyer@.comcast.net> wrote in message
news:OK%23WxcvqGHA.1796@.TK2MSFTNGP03.phx.gbl...
> Greetings.
> I have written a nice little application suite used by 8 or so
> workstations, some of which are connected through a VPN. The IT people
> claim that port 1433 is blocked by default by Nortel's Conntivity VPN, and
> they will not make an attempt to change it for fear it will muck up the
> works elsewhere. As the SQL server (actually, an instance of MSDE) lives
> on a dedicated little WinXP Pro box which does nothing else, I recommended
> they open port 1433 on their router and point it to that box, allowing the
> offsites to circumvent the VPN altogether. The IT director looked at me
> point blank and stated that would mean anyone could come in and "hack"
> both their Win2k Server, and their IBM Midrange running OS/400.
> My question - while I understand the director's concern is completely
> irrational... what ACTUAL issues can opening port 1433 to an isolated box
> really raise? Even assuming that the intruder coud bypass the credentials
> (I am using SQL Authentication, gods help me), what could they possibly do
> to anything other than that one MSDE instance?
> Many thanks in advance.
> --
> Hal Meyer, Proprietor
> the patchwerks
> (423) 462-2606
> http://www.thepatchwerks.com
>