Showing posts with label supposed. Show all posts
Showing posts with label supposed. Show all posts

Wednesday, March 21, 2012

Script task Error

I have a script task that is supposed to perform some task but it fails and throws this exception

"Unable to cast COM object of type System._OComObject to class System.Data.Odbc.odbcConnection". Instances of types that represent com components cannot be cast to the types that represent COM components; they can be caste to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the inteface".

Here is the code that throws this

Dim sqlString As String

Dim conn As Odbc.OdbcConnection

Dim da As Odbc.OdbcDataAdapter

Dim ds As Data.DataSet = New Data.DataSet()

sqlString = " SELECT count(*)FROM tmpDAY INNER JOIN tblData ON tmpDAY.CusID = tblData.datFKCusID WHERE(tmpDAY.Serial = tblData.datSerial)"

Dim connName As String = Dts.Connections(0).Name

Try

conn = CType(Dts.Connections(0).AcquireConnection(Nothing), Odbc.OdbcConnection)

da = New Odbc.OdbcDataAdapter(sqlString, conn)

Catch ex As Exception

MsgBox(ex.Message.ToString())

End Try

Any suggestion will be greatly appreciated?

you could try replacing your CType with a normal ODBC connection constructed from a string
i.e. replace
conn = CType(Dts.Connections(0).AcquireConnection(Nothing), Odbc.OdbcConnection)

with

Dim connString As String = Dts.Connections(0).ConnectionString

conn = New Odbc.OdbcConnection(connString)|||

replace:

conn = CType(Dts.Connections(0).AcquireConnection(Nothing), Odbc.OdbcConnection)

with:

conn = New Odbc.OdbcConnection(connectionString)

conn.Open()

Friday, March 9, 2012

Script creation

Hi

I am supposed to give scripts for an installtion at client site.

installing SQL server 2005 Developer edition
some databases already we have
tables
indexes
Stored procedures
jobs

Can u please guide me how to do this?

I am new to this.

Muralidaran rI would suggest you get a mentor at your current place of employment.|||In SQL Server Management Studio, right-click on your database and select "Script Database as...".|||Dump and restore|||The jobs will need to be scripted separately from the database, however
(which, incidentally, irritates the hell out of me).

Don't forget to check the appropriate options when you are scripting though, and remember that sp_change_users_login can be helpful to get your userid's back in synch.

Mi Perro, you have a huge pile of work before you...if'n I was you I'd start (a) asking for a mentor at my place of employment, (b) ask if perhaps this task can be given to someone who is not "new to this", (c) updating my resume, or (d) all of the above.

If this is anything other than a training exercise, and you are actually building a representative product at your client's site, you probably need to be more than "new at this", and hopefully your company management would agree.