Showing posts with label excuting. Show all posts
Showing posts with label excuting. Show all posts

Wednesday, March 21, 2012

Script Task Error --Object reference not set to an instance of an object

I am trying to execute this code feom Script task while excuting its giving me error that "Object reference not set to an instance of an object." The assemblies Iam referening in this code are there in GAC. Any idea abt this.

Thanks,

PublicSub Main()

Dim remoteUri AsString

Dim fireAgain AsBoolean

Dim uriVarName AsString

Dim fileVarName AsString

Dim httpConnection As Microsoft.SqlServer.Dts.Runtime.HttpClientConnection

Dim emptyBytes(0) AsByte

Dim SessionID AsString

Dim CusAuth As CustomAuth

Try

' Determine the correct variables to read for URI and filename

uriVarName = "vsReportUri"

fileVarName = "vsReportDownloadFilename"

' create SessionID for use with HD Custom authentication

CusAuth = New CustomAuth(ASCIIEncoding.ASCII.GetBytes(Dts.Variables("in_vsBatchKey").Value.ToString()))

Dts.Variables(uriVarName).Value = Dts.Variables(uriVarName).Value.ToString() + "&" + _

"BeginDate=" + Dts.Variables("in_vsBeginDate").Value.ToString() + "&" + _

"EndDate=" + Dts.Variables("in_vsEndDate").Value.ToString()

Dim request As HttpWebRequest = CType(WebRequest.Create(Dts.Variables(uriVarName).Value.ToString()), HttpWebRequest)

'Set credentials based on the credentials found in the variables

request.Credentials = New NetworkCredential(Dts.Variables("in_vsReportUsername").Value.ToString(), _

Dts.Variables("in_vsReportPassword").Value.ToString(), _

Dts.Variables("in_vsReportDomain").Value.ToString())

'Place the custom authentication session ID in a cookie called BatchSession

request.CookieContainer.Add(New Cookie("BatchSession", CusAuth.GenerateSession("EmailAlertingSSIS"), "/", Dts.Variables("in_vsReportDomain").Value.ToString()))

' Set some reasonable limits on resources used by this request

request.MaximumAutomaticRedirections = 4

request.MaximumResponseHeadersLength = 4

' Prepare to download, write messages indicating download start

Dts.Events.FireInformation(0, String.Empty, String.Format("Downloading '{0}' from '{1}'", _

Dts.Variables(fileVarName).Value.ToString(), Dts.Variables(uriVarName).Value.ToString()), String.Empty, 0, fireAgain)

Dts.Log(String.Format("Downloading '{0}' from '{1}'", Dts.Variables(fileVarName).Value.ToString(), Dts.Variables(uriVarName).Value.ToString()), 0, emptyBytes)

' Download data

Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)

' Get the stream associated with the response.

Dim receiveStream As Stream = response.GetResponseStream()

' Pipes the stream to a higher level stream reader with the required encoding format.

Dim readStream AsNew StreamReader(receiveStream, Encoding.UTF8)

Dim fileStream AsNew StreamWriter(Dts.Variables(fileVarName).Value.ToString())

fileStream.Write(readStream.ReadToEnd())

fileStream.Flush()

fileStream.Close()

readStream.Close()

fileStream.Dispose()

readStream.Dispose()

'Download the file and report success

Dts.TaskResult = Dts.Results.Success

Catch ex As Exception

' post the error message we got back.

Dts.Events.FireError(0, String.Empty, ex.Message, String.Empty, 0)

Dts.TaskResult = Dts.Results.Failure

EndTry

EndSub

It isn't clear what is failing, a line number or similar would help. Since you mention external assemblies, have you read this -

Referencing Other Assemblies in Scripting Solutions
(http://msdn2.microsoft.com/en-us/library/9b655bcd-19f6-43d8-9f89-1b4d299c6380.aspx)

Script Syntax Errors

i have new server, win2003, sql2005. trying to restore a .bak file from
sql2000. when excuting the RESTORE DATABASE dbase1 from
disk='c:\dbasebackup.bak' command, or using FILELISTONLY, the error below is
displayed.
Executing the query ...
Query (1, 9) Parser: The syntax for 'database' is incorrect.
Execution complete
any ideas?
thanks in advance.
paulWhere do you execute this restore command? The error seems like some client application error...
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"paul" <paul@.discussions.microsoft.com> wrote in message
news:2DBA2DA0-FEE5-481A-AF28-E1D9558BFE05@.microsoft.com...
>i have new server, win2003, sql2005. trying to restore a .bak file from
> sql2000. when excuting the RESTORE DATABASE dbase1 from
> disk='c:\dbasebackup.bak' command, or using FILELISTONLY, the error below is
> displayed.
> Executing the query ...
> Query (1, 9) Parser: The syntax for 'database' is incorrect.
> Execution complete
> any ideas?
> thanks in advance.
> paul|||i'm in the server management studio, right click on the database, new query,
mdx.
thanks.
paul
"Tibor Karaszi" wrote:
> Where do you execute this restore command? The error seems like some client application error...
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "paul" <paul@.discussions.microsoft.com> wrote in message
> news:2DBA2DA0-FEE5-481A-AF28-E1D9558BFE05@.microsoft.com...
> >i have new server, win2003, sql2005. trying to restore a .bak file from
> > sql2000. when excuting the RESTORE DATABASE dbase1 from
> > disk='c:\dbasebackup.bak' command, or using FILELISTONLY, the error below is
> > displayed.
> >
> > Executing the query ...
> > Query (1, 9) Parser: The syntax for 'database' is incorrect.
> > Execution complete
> >
> > any ideas?
> > thanks in advance.
> > paul
>|||mdx? Seems you have connected to Analysis server. The restore command you posted is a SQL Server
command.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"paul" <paul@.discussions.microsoft.com> wrote in message
news:13EB6139-0A6A-4F67-9F6F-12B430BE9DC3@.microsoft.com...
> i'm in the server management studio, right click on the database, new query,
> mdx.
> thanks.
> paul
> "Tibor Karaszi" wrote:
>> Where do you execute this restore command? The error seems like some client application error...
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "paul" <paul@.discussions.microsoft.com> wrote in message
>> news:2DBA2DA0-FEE5-481A-AF28-E1D9558BFE05@.microsoft.com...
>> >i have new server, win2003, sql2005. trying to restore a .bak file from
>> > sql2000. when excuting the RESTORE DATABASE dbase1 from
>> > disk='c:\dbasebackup.bak' command, or using FILELISTONLY, the error below is
>> > displayed.
>> >
>> > Executing the query ...
>> > Query (1, 9) Parser: The syntax for 'database' is incorrect.
>> > Execution complete
>> >
>> > any ideas?
>> > thanks in advance.
>> > paul
>>|||oops, you are correct.
thanks.
when i try to connect to Database Engines a connection error is displayed;
name pipes provider error 40 and ms sql server error 53
"Tibor Karaszi" wrote:
> mdx? Seems you have connected to Analysis server. The restore command you posted is a SQL Server
> command.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "paul" <paul@.discussions.microsoft.com> wrote in message
> news:13EB6139-0A6A-4F67-9F6F-12B430BE9DC3@.microsoft.com...
> > i'm in the server management studio, right click on the database, new query,
> > mdx.
> > thanks.
> > paul
> >
> > "Tibor Karaszi" wrote:
> >
> >> Where do you execute this restore command? The error seems like some client application error...
> >>
> >> --
> >> Tibor Karaszi, SQL Server MVP
> >> http://www.karaszi.com/sqlserver/default.asp
> >> http://sqlblog.com/blogs/tibor_karaszi
> >>
> >>
> >> "paul" <paul@.discussions.microsoft.com> wrote in message
> >> news:2DBA2DA0-FEE5-481A-AF28-E1D9558BFE05@.microsoft.com...
> >> >i have new server, win2003, sql2005. trying to restore a .bak file from
> >> > sql2000. when excuting the RESTORE DATABASE dbase1 from
> >> > disk='c:\dbasebackup.bak' command, or using FILELISTONLY, the error below is
> >> > displayed.
> >> >
> >> > Executing the query ...
> >> > Query (1, 9) Parser: The syntax for 'database' is incorrect.
> >> > Execution complete
> >> >
> >> > any ideas?
> >> > thanks in advance.
> >> > paul
> >>
> >>
>|||Make sure the server is listening on appropriate netlibs (SQL Server Configuration Manager).
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"paul" <paul@.discussions.microsoft.com> wrote in message
news:7FB8AAE2-17F5-4BCB-9E53-CBF44547A053@.microsoft.com...
> oops, you are correct.
> thanks.
> when i try to connect to Database Engines a connection error is displayed;
> name pipes provider error 40 and ms sql server error 53
>
> "Tibor Karaszi" wrote:
>> mdx? Seems you have connected to Analysis server. The restore command you posted is a SQL Server
>> command.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "paul" <paul@.discussions.microsoft.com> wrote in message
>> news:13EB6139-0A6A-4F67-9F6F-12B430BE9DC3@.microsoft.com...
>> > i'm in the server management studio, right click on the database, new query,
>> > mdx.
>> > thanks.
>> > paul
>> >
>> > "Tibor Karaszi" wrote:
>> >
>> >> Where do you execute this restore command? The error seems like some client application
>> >> error...
>> >>
>> >> --
>> >> Tibor Karaszi, SQL Server MVP
>> >> http://www.karaszi.com/sqlserver/default.asp
>> >> http://sqlblog.com/blogs/tibor_karaszi
>> >>
>> >>
>> >> "paul" <paul@.discussions.microsoft.com> wrote in message
>> >> news:2DBA2DA0-FEE5-481A-AF28-E1D9558BFE05@.microsoft.com...
>> >> >i have new server, win2003, sql2005. trying to restore a .bak file from
>> >> > sql2000. when excuting the RESTORE DATABASE dbase1 from
>> >> > disk='c:\dbasebackup.bak' command, or using FILELISTONLY, the error below is
>> >> > displayed.
>> >> >
>> >> > Executing the query ...
>> >> > Query (1, 9) Parser: The syntax for 'database' is incorrect.
>> >> > Execution complete
>> >> >
>> >> > any ideas?
>> >> > thanks in advance.
>> >> > paul
>> >>
>> >>
>>|||in SQL Server Config Manager there are 3 items listed; Service, Network
Config, Client Config.
in Services all are running; Integration,Analysis,Reporting, and Browser
in Network Config there are no items listed
in Client config, Protocols, all are running; Shared, NamePipes, TCP/IP, and
VIA
thanks.
paul
"Tibor Karaszi" wrote:
> Make sure the server is listening on appropriate netlibs (SQL Server Configuration Manager).
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "paul" <paul@.discussions.microsoft.com> wrote in message
> news:7FB8AAE2-17F5-4BCB-9E53-CBF44547A053@.microsoft.com...
> > oops, you are correct.
> > thanks.
> >
> > when i try to connect to Database Engines a connection error is displayed;
> > name pipes provider error 40 and ms sql server error 53
> >
> >
> >
> > "Tibor Karaszi" wrote:
> >
> >> mdx? Seems you have connected to Analysis server. The restore command you posted is a SQL Server
> >> command.
> >>
> >> --
> >> Tibor Karaszi, SQL Server MVP
> >> http://www.karaszi.com/sqlserver/default.asp
> >> http://sqlblog.com/blogs/tibor_karaszi
> >>
> >>
> >> "paul" <paul@.discussions.microsoft.com> wrote in message
> >> news:13EB6139-0A6A-4F67-9F6F-12B430BE9DC3@.microsoft.com...
> >> > i'm in the server management studio, right click on the database, new query,
> >> > mdx.
> >> > thanks.
> >> > paul
> >> >
> >> > "Tibor Karaszi" wrote:
> >> >
> >> >> Where do you execute this restore command? The error seems like some client application
> >> >> error...
> >> >>
> >> >> --
> >> >> Tibor Karaszi, SQL Server MVP
> >> >> http://www.karaszi.com/sqlserver/default.asp
> >> >> http://sqlblog.com/blogs/tibor_karaszi
> >> >>
> >> >>
> >> >> "paul" <paul@.discussions.microsoft.com> wrote in message
> >> >> news:2DBA2DA0-FEE5-481A-AF28-E1D9558BFE05@.microsoft.com...
> >> >> >i have new server, win2003, sql2005. trying to restore a .bak file from
> >> >> > sql2000. when excuting the RESTORE DATABASE dbase1 from
> >> >> > disk='c:\dbasebackup.bak' command, or using FILELISTONLY, the error below is
> >> >> > displayed.
> >> >> >
> >> >> > Executing the query ...
> >> >> > Query (1, 9) Parser: The syntax for 'database' is incorrect.
> >> >> > Execution complete
> >> >> >
> >> >> > any ideas?
> >> >> > thanks in advance.
> >> >> > paul
> >> >>
> >> >>
> >>
> >>
>|||Seems you didn't install SQL Server:
> in Services all are running; Integration,Analysis,Reporting, and Browser
If you had installed SQL Server, you would have also a "SQL Server" service.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"paul" <paul@.discussions.microsoft.com> wrote in message
news:BFEF1B78-052E-4EB1-8A9A-D3804256436C@.microsoft.com...
> in SQL Server Config Manager there are 3 items listed; Service, Network
> Config, Client Config.
> in Services all are running; Integration,Analysis,Reporting, and Browser
> in Network Config there are no items listed
> in Client config, Protocols, all are running; Shared, NamePipes, TCP/IP, and
> VIA
> thanks.
> paul
> "Tibor Karaszi" wrote:
>> Make sure the server is listening on appropriate netlibs (SQL Server Configuration Manager).
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "paul" <paul@.discussions.microsoft.com> wrote in message
>> news:7FB8AAE2-17F5-4BCB-9E53-CBF44547A053@.microsoft.com...
>> > oops, you are correct.
>> > thanks.
>> >
>> > when i try to connect to Database Engines a connection error is displayed;
>> > name pipes provider error 40 and ms sql server error 53
>> >
>> >
>> >
>> > "Tibor Karaszi" wrote:
>> >
>> >> mdx? Seems you have connected to Analysis server. The restore command you posted is a SQL
>> >> Server
>> >> command.
>> >>
>> >> --
>> >> Tibor Karaszi, SQL Server MVP
>> >> http://www.karaszi.com/sqlserver/default.asp
>> >> http://sqlblog.com/blogs/tibor_karaszi
>> >>
>> >>
>> >> "paul" <paul@.discussions.microsoft.com> wrote in message
>> >> news:13EB6139-0A6A-4F67-9F6F-12B430BE9DC3@.microsoft.com...
>> >> > i'm in the server management studio, right click on the database, new query,
>> >> > mdx.
>> >> > thanks.
>> >> > paul
>> >> >
>> >> > "Tibor Karaszi" wrote:
>> >> >
>> >> >> Where do you execute this restore command? The error seems like some client application
>> >> >> error...
>> >> >>
>> >> >> --
>> >> >> Tibor Karaszi, SQL Server MVP
>> >> >> http://www.karaszi.com/sqlserver/default.asp
>> >> >> http://sqlblog.com/blogs/tibor_karaszi
>> >> >>
>> >> >>
>> >> >> "paul" <paul@.discussions.microsoft.com> wrote in message
>> >> >> news:2DBA2DA0-FEE5-481A-AF28-E1D9558BFE05@.microsoft.com...
>> >> >> >i have new server, win2003, sql2005. trying to restore a .bak file from
>> >> >> > sql2000. when excuting the RESTORE DATABASE dbase1 from
>> >> >> > disk='c:\dbasebackup.bak' command, or using FILELISTONLY, the error below is
>> >> >> > displayed.
>> >> >> >
>> >> >> > Executing the query ...
>> >> >> > Query (1, 9) Parser: The syntax for 'database' is incorrect.
>> >> >> > Execution complete
>> >> >> >
>> >> >> > any ideas?
>> >> >> > thanks in advance.
>> >> >> > paul
>> >> >>
>> >> >>
>> >>
>> >>
>>|||i'm an idiot.
thanks.
paul
"Tibor Karaszi" wrote:
> Seems you didn't install SQL Server:
> > in Services all are running; Integration,Analysis,Reporting, and Browser
> If you had installed SQL Server, you would have also a "SQL Server" service.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "paul" <paul@.discussions.microsoft.com> wrote in message
> news:BFEF1B78-052E-4EB1-8A9A-D3804256436C@.microsoft.com...
> > in SQL Server Config Manager there are 3 items listed; Service, Network
> > Config, Client Config.
> >
> > in Services all are running; Integration,Analysis,Reporting, and Browser
> > in Network Config there are no items listed
> > in Client config, Protocols, all are running; Shared, NamePipes, TCP/IP, and
> > VIA
> >
> > thanks.
> > paul
> >
> > "Tibor Karaszi" wrote:
> >
> >> Make sure the server is listening on appropriate netlibs (SQL Server Configuration Manager).
> >>
> >> --
> >> Tibor Karaszi, SQL Server MVP
> >> http://www.karaszi.com/sqlserver/default.asp
> >> http://sqlblog.com/blogs/tibor_karaszi
> >>
> >>
> >> "paul" <paul@.discussions.microsoft.com> wrote in message
> >> news:7FB8AAE2-17F5-4BCB-9E53-CBF44547A053@.microsoft.com...
> >> > oops, you are correct.
> >> > thanks.
> >> >
> >> > when i try to connect to Database Engines a connection error is displayed;
> >> > name pipes provider error 40 and ms sql server error 53
> >> >
> >> >
> >> >
> >> > "Tibor Karaszi" wrote:
> >> >
> >> >> mdx? Seems you have connected to Analysis server. The restore command you posted is a SQL
> >> >> Server
> >> >> command.
> >> >>
> >> >> --
> >> >> Tibor Karaszi, SQL Server MVP
> >> >> http://www.karaszi.com/sqlserver/default.asp
> >> >> http://sqlblog.com/blogs/tibor_karaszi
> >> >>
> >> >>
> >> >> "paul" <paul@.discussions.microsoft.com> wrote in message
> >> >> news:13EB6139-0A6A-4F67-9F6F-12B430BE9DC3@.microsoft.com...
> >> >> > i'm in the server management studio, right click on the database, new query,
> >> >> > mdx.
> >> >> > thanks.
> >> >> > paul
> >> >> >
> >> >> > "Tibor Karaszi" wrote:
> >> >> >
> >> >> >> Where do you execute this restore command? The error seems like some client application
> >> >> >> error...
> >> >> >>
> >> >> >> --
> >> >> >> Tibor Karaszi, SQL Server MVP
> >> >> >> http://www.karaszi.com/sqlserver/default.asp
> >> >> >> http://sqlblog.com/blogs/tibor_karaszi
> >> >> >>
> >> >> >>
> >> >> >> "paul" <paul@.discussions.microsoft.com> wrote in message
> >> >> >> news:2DBA2DA0-FEE5-481A-AF28-E1D9558BFE05@.microsoft.com...
> >> >> >> >i have new server, win2003, sql2005. trying to restore a .bak file from
> >> >> >> > sql2000. when excuting the RESTORE DATABASE dbase1 from
> >> >> >> > disk='c:\dbasebackup.bak' command, or using FILELISTONLY, the error below is
> >> >> >> > displayed.
> >> >> >> >
> >> >> >> > Executing the query ...
> >> >> >> > Query (1, 9) Parser: The syntax for 'database' is incorrect.
> >> >> >> > Execution complete
> >> >> >> >
> >> >> >> > any ideas?
> >> >> >> > thanks in advance.
> >> >> >> > paul
> >> >> >>
> >> >> >>
> >> >>
> >> >>
> >>
> >>
>