Showing posts with label exception. Show all posts
Showing posts with label exception. Show all posts

Tuesday, March 27, 2012

Error: Cannot open database requested in login projectAllocations. Login fails. Login fail

Hi,
Im getting this error when attempting to retrieve data from an sql database.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Cannot open database requested in login 'projectAllocations'. Login fails. Login failed for user 'sa'.

Source Error:

Line 13: objConn = New SqlConnection( "Server=LAB303-066\NETSDK; Database=projectAllocations; User ID=sa;Password=mypassword")
Line 14: objCmd = New SqlCommand("SELECT * FROM project_descriptions", objConn)
Line 15: objConn.Open()
Line 16: objRdr = objCmd.ExecuteReader()
Line 17: While objRdr.Read()

Source File: C:\finalyearproject2\sample.aspx Line: 15

Please Help!! Im a beginner to this, so if anyone knows the answer, take baby steps when explaining. Thanksas the message says you prbly need to give permissions to the user to access the database. in your enterprise manager, if you xpand the databases tab and then the db you are working on, there's a Users tab. click on it and in the panel to your right you would see a list of users. You might need to add the user "projectAllocations" to the list here and give permissions to the user to access the tables/stored procs and other objects..

hth|||Hi,
Thanks for the response. When I login to the web data administrator and expad the database im workin on, there is no users tab. Does the database have to be empty to do this?|||>>in your enterprise manager, if you xpand the databases tab

Error: Arithmetic overflow error converting numeric to data type numeric

Hello,
I'm using adonet to update the database hundreds of fields all at once and
got this exception/error:
"Arithmetic overflow error converting numeric to data type numeric", but it
doesn't tell me which specific column got overflown. Is there a way to find
out ? I have access to both the update code and the sql server.
Thank you very much in advance...Although I am not much of an ADO.Net person, I think that you get an errors
collection... SQL does return more info... Either it is in one of the other
messages or the one you are seeing is truncated... I did an arithmetic
overflow and got the following message..
Server: Msg 220, Level 16, State 2, Line 2
Arithmetic overflow error for data type tinyint, value = 3500.
--
Wayne Snyder, MCDBA, SQL Server MVP
Computer Education Services Corporation (CESC), Charlotte, NC
www.computeredservices.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Zeng" <zzy@.nonospam.com> wrote in message
news:%23Whl0SBJEHA.2440@.TK2MSFTNGP12.phx.gbl...
> Hello,
> I'm using adonet to update the database hundreds of fields all at once and
> got this exception/error:
> "Arithmetic overflow error converting numeric to data type numeric", but
it
> doesn't tell me which specific column got overflown. Is there a way to
find
> out ? I have access to both the update code and the sql server.
> Thank you very much in advance...
>|||hii
change the size of all your numeric fields in th data base to 38 and
precison to 0 and see..
ramesh|||If I don't error the error after that, how would I know which one?
"Ramesh" <ramesh@.mail.punecity.com> wrote in message
news:uJe8DkDKEHA.268@.TK2MSFTNGP11.phx.gbl...
> hii
> change the size of all your numeric fields in th data base to 38 and
> precison to 0 and see..
> ramesh
>sql

Error: Arithmetic overflow error converting numeric to data type numeric

Hello,
I'm using adonet to update the database hundreds of fields all at once and
got this exception/error:
"Arithmetic overflow error converting numeric to data type numeric", but it
doesn't tell me which specific column got overflown. Is there a way to find
out ? I have access to both the update code and the sql server.
Thank you very much in advance...Although I am not much of an ADO.Net person, I think that you get an errors
collection... SQL does return more info... Either it is in one of the other
messages or the one you are seeing is truncated... I did an arithmetic
overflow and got the following message..
Server: Msg 220, Level 16, State 2, Line 2
Arithmetic overflow error for data type tinyint, value = 3500.
Wayne Snyder, MCDBA, SQL Server MVP
Computer Education Services Corporation (CESC), Charlotte, NC
www.computeredservices.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Zeng" <zzy@.nonospam.com> wrote in message
news:%23Whl0SBJEHA.2440@.TK2MSFTNGP12.phx.gbl...
> Hello,
> I'm using adonet to update the database hundreds of fields all at once and
> got this exception/error:
> "Arithmetic overflow error converting numeric to data type numeric", but
it
> doesn't tell me which specific column got overflown. Is there a way to
find
> out ? I have access to both the update code and the sql server.
> Thank you very much in advance...
>|||hii
change the size of all your numeric fields in th data base to 38 and
precison to 0 and see..
ramesh|||If I don't error the error after that, how would I know which one?
"Ramesh" <ramesh@.mail.punecity.com> wrote in message
news:uJe8DkDKEHA.268@.TK2MSFTNGP11.phx.gbl...
> hii
> change the size of all your numeric fields in th data base to 38 and
> precison to 0 and see..
> ramesh
>

Error: Arithmetic overflow error converting numeric to data type numeric

Hello,
I'm using adonet to update the database hundreds of fields all at once and
got this exception/error:
"Arithmetic overflow error converting numeric to data type numeric", but it
doesn't tell me which specific column got overflown. Is there a way to find
out ? I have access to both the update code and the sql server.
Thank you very much in advance...
Although I am not much of an ADO.Net person, I think that you get an errors
collection... SQL does return more info... Either it is in one of the other
messages or the one you are seeing is truncated... I did an arithmetic
overflow and got the following message..
Server: Msg 220, Level 16, State 2, Line 2
Arithmetic overflow error for data type tinyint, value = 3500.
Wayne Snyder, MCDBA, SQL Server MVP
Computer Education Services Corporation (CESC), Charlotte, NC
www.computeredservices.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Zeng" <zzy@.nonospam.com> wrote in message
news:%23Whl0SBJEHA.2440@.TK2MSFTNGP12.phx.gbl...
> Hello,
> I'm using adonet to update the database hundreds of fields all at once and
> got this exception/error:
> "Arithmetic overflow error converting numeric to data type numeric", but
it
> doesn't tell me which specific column got overflown. Is there a way to
find
> out ? I have access to both the update code and the sql server.
> Thank you very much in advance...
>
|||hii
change the size of all your numeric fields in th data base to 38 and
precison to 0 and see..
ramesh
|||If I don't error the error after that, how would I know which one?
"Ramesh" <ramesh@.mail.punecity.com> wrote in message
news:uJe8DkDKEHA.268@.TK2MSFTNGP11.phx.gbl...
> hii
> change the size of all your numeric fields in th data base to 38 and
> precison to 0 and see..
> ramesh
>

Monday, March 19, 2012

Error: 17053, Severity: 16, State: 1. Exception 0xAE

I have recieved billions of:
2006-09-22 02:07:06.76 spid11s Error: 17053, Severity: 16, State: 1.
2006-09-22 02:07:06.76 spid11s High priority system task thread:
Operating system error Exception 0xAE encountered.
in my log and it has grown enormous. What is causing this, how can I stop it
and how can i cut my log file out so i can keep it running until we find a
solution?
Bryan
What version and service pack of SQL?
Look at sp_cycle_errorlog to restart the log...
Kevin Hill
3NF Consulting
www.3nf-inc.com/NewsGroups.htm
"Bryan Aldrich" <BryanAldrich@.discussions.microsoft.com> wrote in message
news:45F47E8B-4060-418F-8385-1081C52C8D18@.microsoft.com...
>I have recieved billions of:
> 2006-09-22 02:07:06.76 spid11s Error: 17053, Severity: 16, State: 1.
> 2006-09-22 02:07:06.76 spid11s High priority system task thread:
> Operating system error Exception 0xAE encountered.
> in my log and it has grown enormous. What is causing this, how can I stop
> it
> and how can i cut my log file out so i can keep it running until we find a
> solution?
> Bryan
|||It was on SP1 Enterprise Edition.
We called PSS and they recommended putting on hotfix 2153. It has not come
back since. We are still monitoring. Thanks for the tip about rotating the
log.
Bryan
"Kevin3NF" wrote:

> What version and service pack of SQL?
> Look at sp_cycle_errorlog to restart the log...
> --
> Kevin Hill
> 3NF Consulting
> www.3nf-inc.com/NewsGroups.htm
>
>
> "Bryan Aldrich" <BryanAldrich@.discussions.microsoft.com> wrote in message
> news:45F47E8B-4060-418F-8385-1081C52C8D18@.microsoft.com...
>
>
|||Hotfix rollup .2187 is better and more stable. Surprised they didn't take
you there instead.
I assume you meant SQL 2000 sp4, not sp1
Kevin Hill
3NF Consulting
www.3nf-inc.com/NewsGroups.htm
"Bryan Aldrich" <BryanAldrich@.discussions.microsoft.com> wrote in message
news:5584B7BB-4211-4B2E-96AD-D5323CA959C1@.microsoft.com...[vbcol=seagreen]
> It was on SP1 Enterprise Edition.
> We called PSS and they recommended putting on hotfix 2153. It has not come
> back since. We are still monitoring. Thanks for the tip about rotating the
> log.
> Bryan
> "Kevin3NF" wrote:
|||This is Sql 2005, not 2000. We still have the option to goto 2187 if we need
to. We don't have much information on it though.
Is where somewhere where we can get a list of fixes in 2187?
Bryan
"Kevin3NF" wrote:

> Hotfix rollup .2187 is better and more stable. Surprised they didn't take
> you there instead.
> I assume you meant SQL 2000 sp4, not sp1
> --
> Kevin Hill
> 3NF Consulting
> www.3nf-inc.com/NewsGroups.htm
>
>
> "Bryan Aldrich" <BryanAldrich@.discussions.microsoft.com> wrote in message
> news:5584B7BB-4211-4B2E-96AD-D5323CA959C1@.microsoft.com...
>
>
|||The only .2187 I know of is a post sp4 rollup.
But, I am completely ignorant in terms of 2005
Email whoever helped you in PSS. THey should answer that qestion without
any haslle, even if the case is already closed.
Kevin Hill
3NF Consulting
www.3nf-inc.com/NewsGroups.htm
"Bryan Aldrich" <BryanAldrich@.discussions.microsoft.com> wrote in message
news:33727070-BAC8-49C3-8222-5AFF0B9738E5@.microsoft.com...[vbcol=seagreen]
> This is Sql 2005, not 2000. We still have the option to goto 2187 if we
> need
> to. We don't have much information on it though.
> Is where somewhere where we can get a list of fixes in 2187?
> Bryan
> "Kevin3NF" wrote:

Error: 17053, Severity: 16, State: 1. Exception 0xAE

I have recieved billions of:
2006-09-22 02:07:06.76 spid11s Error: 17053, Severity: 16, State: 1.
2006-09-22 02:07:06.76 spid11s High priority system task thread:
Operating system error Exception 0xAE encountered.
in my log and it has grown enormous. What is causing this, how can I stop it
and how can i cut my log file out so i can keep it running until we find a
solution?
BryanWhat version and service pack of SQL?
Look at sp_cycle_errorlog to restart the log...
--
Kevin Hill
3NF Consulting
www.3nf-inc.com/NewsGroups.htm
"Bryan Aldrich" <BryanAldrich@.discussions.microsoft.com> wrote in message
news:45F47E8B-4060-418F-8385-1081C52C8D18@.microsoft.com...
>I have recieved billions of:
> 2006-09-22 02:07:06.76 spid11s Error: 17053, Severity: 16, State: 1.
> 2006-09-22 02:07:06.76 spid11s High priority system task thread:
> Operating system error Exception 0xAE encountered.
> in my log and it has grown enormous. What is causing this, how can I stop
> it
> and how can i cut my log file out so i can keep it running until we find a
> solution?
> Bryan|||It was on SP1 Enterprise Edition.
We called PSS and they recommended putting on hotfix 2153. It has not come
back since. We are still monitoring. Thanks for the tip about rotating the
log.
Bryan
"Kevin3NF" wrote:

> What version and service pack of SQL?
> Look at sp_cycle_errorlog to restart the log...
> --
> Kevin Hill
> 3NF Consulting
> www.3nf-inc.com/NewsGroups.htm
>
>
> "Bryan Aldrich" <BryanAldrich@.discussions.microsoft.com> wrote in message
> news:45F47E8B-4060-418F-8385-1081C52C8D18@.microsoft.com...
>
>|||Hotfix rollup .2187 is better and more stable. Surprised they didn't take
you there instead.
I assume you meant SQL 2000 sp4, not sp1
Kevin Hill
3NF Consulting
www.3nf-inc.com/NewsGroups.htm
"Bryan Aldrich" <BryanAldrich@.discussions.microsoft.com> wrote in message
news:5584B7BB-4211-4B2E-96AD-D5323CA959C1@.microsoft.com...[vbcol=seagreen]
> It was on SP1 Enterprise Edition.
> We called PSS and they recommended putting on hotfix 2153. It has not come
> back since. We are still monitoring. Thanks for the tip about rotating the
> log.
> Bryan
> "Kevin3NF" wrote:
>|||This is Sql 2005, not 2000. We still have the option to goto 2187 if we need
to. We don't have much information on it though.
Is where somewhere where we can get a list of fixes in 2187?
Bryan
"Kevin3NF" wrote:

> Hotfix rollup .2187 is better and more stable. Surprised they didn't take
> you there instead.
> I assume you meant SQL 2000 sp4, not sp1
> --
> Kevin Hill
> 3NF Consulting
> www.3nf-inc.com/NewsGroups.htm
>
>
> "Bryan Aldrich" <BryanAldrich@.discussions.microsoft.com> wrote in message
> news:5584B7BB-4211-4B2E-96AD-D5323CA959C1@.microsoft.com...
>
>|||The only .2187 I know of is a post sp4 rollup.
But, I am completely ignorant in terms of 2005
Email whoever helped you in PSS. THey should answer that qestion without
any haslle, even if the case is already closed.
Kevin Hill
3NF Consulting
www.3nf-inc.com/NewsGroups.htm
"Bryan Aldrich" <BryanAldrich@.discussions.microsoft.com> wrote in message
news:33727070-BAC8-49C3-8222-5AFF0B9738E5@.microsoft.com...[vbcol=seagreen]
> This is Sql 2005, not 2000. We still have the option to goto 2187 if we
> need
> to. We don't have much information on it though.
> Is where somewhere where we can get a list of fixes in 2187?
> Bryan
> "Kevin3NF" wrote:
>

Error: 17053, Severity: 16, State: 1. Exception 0xAE

I have recieved billions of:
2006-09-22 02:07:06.76 spid11s Error: 17053, Severity: 16, State: 1.
2006-09-22 02:07:06.76 spid11s High priority system task thread:
Operating system error Exception 0xAE encountered.
in my log and it has grown enormous. What is causing this, how can I stop it
and how can i cut my log file out so i can keep it running until we find a
solution?
BryanWhat version and service pack of SQL?
Look at sp_cycle_errorlog to restart the log...
--
Kevin Hill
3NF Consulting
www.3nf-inc.com/NewsGroups.htm
"Bryan Aldrich" <BryanAldrich@.discussions.microsoft.com> wrote in message
news:45F47E8B-4060-418F-8385-1081C52C8D18@.microsoft.com...
>I have recieved billions of:
> 2006-09-22 02:07:06.76 spid11s Error: 17053, Severity: 16, State: 1.
> 2006-09-22 02:07:06.76 spid11s High priority system task thread:
> Operating system error Exception 0xAE encountered.
> in my log and it has grown enormous. What is causing this, how can I stop
> it
> and how can i cut my log file out so i can keep it running until we find a
> solution?
> Bryan|||It was on SP1 Enterprise Edition.
We called PSS and they recommended putting on hotfix 2153. It has not come
back since. We are still monitoring. Thanks for the tip about rotating the
log.
Bryan
"Kevin3NF" wrote:
> What version and service pack of SQL?
> Look at sp_cycle_errorlog to restart the log...
> --
> Kevin Hill
> 3NF Consulting
> www.3nf-inc.com/NewsGroups.htm
>
>
> "Bryan Aldrich" <BryanAldrich@.discussions.microsoft.com> wrote in message
> news:45F47E8B-4060-418F-8385-1081C52C8D18@.microsoft.com...
> >I have recieved billions of:
> >
> > 2006-09-22 02:07:06.76 spid11s Error: 17053, Severity: 16, State: 1.
> > 2006-09-22 02:07:06.76 spid11s High priority system task thread:
> > Operating system error Exception 0xAE encountered.
> >
> > in my log and it has grown enormous. What is causing this, how can I stop
> > it
> > and how can i cut my log file out so i can keep it running until we find a
> > solution?
> >
> > Bryan
>
>|||Hotfix rollup .2187 is better and more stable. Surprised they didn't take
you there instead.
I assume you meant SQL 2000 sp4, not sp1
--
Kevin Hill
3NF Consulting
www.3nf-inc.com/NewsGroups.htm
"Bryan Aldrich" <BryanAldrich@.discussions.microsoft.com> wrote in message
news:5584B7BB-4211-4B2E-96AD-D5323CA959C1@.microsoft.com...
> It was on SP1 Enterprise Edition.
> We called PSS and they recommended putting on hotfix 2153. It has not come
> back since. We are still monitoring. Thanks for the tip about rotating the
> log.
> Bryan
> "Kevin3NF" wrote:
>> What version and service pack of SQL?
>> Look at sp_cycle_errorlog to restart the log...
>> --
>> Kevin Hill
>> 3NF Consulting
>> www.3nf-inc.com/NewsGroups.htm
>>
>>
>> "Bryan Aldrich" <BryanAldrich@.discussions.microsoft.com> wrote in message
>> news:45F47E8B-4060-418F-8385-1081C52C8D18@.microsoft.com...
>> >I have recieved billions of:
>> >
>> > 2006-09-22 02:07:06.76 spid11s Error: 17053, Severity: 16, State:
>> > 1.
>> > 2006-09-22 02:07:06.76 spid11s High priority system task thread:
>> > Operating system error Exception 0xAE encountered.
>> >
>> > in my log and it has grown enormous. What is causing this, how can I
>> > stop
>> > it
>> > and how can i cut my log file out so i can keep it running until we
>> > find a
>> > solution?
>> >
>> > Bryan
>>|||This is Sql 2005, not 2000. We still have the option to goto 2187 if we need
to. We don't have much information on it though.
Is where somewhere where we can get a list of fixes in 2187?
Bryan
"Kevin3NF" wrote:
> Hotfix rollup .2187 is better and more stable. Surprised they didn't take
> you there instead.
> I assume you meant SQL 2000 sp4, not sp1
> --
> Kevin Hill
> 3NF Consulting
> www.3nf-inc.com/NewsGroups.htm
>
>
> "Bryan Aldrich" <BryanAldrich@.discussions.microsoft.com> wrote in message
> news:5584B7BB-4211-4B2E-96AD-D5323CA959C1@.microsoft.com...
> > It was on SP1 Enterprise Edition.
> >
> > We called PSS and they recommended putting on hotfix 2153. It has not come
> > back since. We are still monitoring. Thanks for the tip about rotating the
> > log.
> >
> > Bryan
> >
> > "Kevin3NF" wrote:
> >
> >> What version and service pack of SQL?
> >>
> >> Look at sp_cycle_errorlog to restart the log...
> >> --
> >> Kevin Hill
> >> 3NF Consulting
> >> www.3nf-inc.com/NewsGroups.htm
> >>
> >>
> >>
> >>
> >> "Bryan Aldrich" <BryanAldrich@.discussions.microsoft.com> wrote in message
> >> news:45F47E8B-4060-418F-8385-1081C52C8D18@.microsoft.com...
> >> >I have recieved billions of:
> >> >
> >> > 2006-09-22 02:07:06.76 spid11s Error: 17053, Severity: 16, State:
> >> > 1.
> >> > 2006-09-22 02:07:06.76 spid11s High priority system task thread:
> >> > Operating system error Exception 0xAE encountered.
> >> >
> >> > in my log and it has grown enormous. What is causing this, how can I
> >> > stop
> >> > it
> >> > and how can i cut my log file out so i can keep it running until we
> >> > find a
> >> > solution?
> >> >
> >> > Bryan
> >>
> >>
> >>
>
>|||The only .2187 I know of is a post sp4 rollup.
But, I am completely ignorant in terms of 2005
Email whoever helped you in PSS. THey should answer that qestion without
any haslle, even if the case is already closed.
--
Kevin Hill
3NF Consulting
www.3nf-inc.com/NewsGroups.htm
"Bryan Aldrich" <BryanAldrich@.discussions.microsoft.com> wrote in message
news:33727070-BAC8-49C3-8222-5AFF0B9738E5@.microsoft.com...
> This is Sql 2005, not 2000. We still have the option to goto 2187 if we
> need
> to. We don't have much information on it though.
> Is where somewhere where we can get a list of fixes in 2187?
> Bryan
> "Kevin3NF" wrote:
>> Hotfix rollup .2187 is better and more stable. Surprised they didn't
>> take
>> you there instead.
>> I assume you meant SQL 2000 sp4, not sp1
>> --
>> Kevin Hill
>> 3NF Consulting
>> www.3nf-inc.com/NewsGroups.htm
>>
>>
>> "Bryan Aldrich" <BryanAldrich@.discussions.microsoft.com> wrote in message
>> news:5584B7BB-4211-4B2E-96AD-D5323CA959C1@.microsoft.com...
>> > It was on SP1 Enterprise Edition.
>> >
>> > We called PSS and they recommended putting on hotfix 2153. It has not
>> > come
>> > back since. We are still monitoring. Thanks for the tip about rotating
>> > the
>> > log.
>> >
>> > Bryan
>> >
>> > "Kevin3NF" wrote:
>> >
>> >> What version and service pack of SQL?
>> >>
>> >> Look at sp_cycle_errorlog to restart the log...
>> >> --
>> >> Kevin Hill
>> >> 3NF Consulting
>> >> www.3nf-inc.com/NewsGroups.htm
>> >>
>> >>
>> >>
>> >>
>> >> "Bryan Aldrich" <BryanAldrich@.discussions.microsoft.com> wrote in
>> >> message
>> >> news:45F47E8B-4060-418F-8385-1081C52C8D18@.microsoft.com...
>> >> >I have recieved billions of:
>> >> >
>> >> > 2006-09-22 02:07:06.76 spid11s Error: 17053, Severity: 16,
>> >> > State:
>> >> > 1.
>> >> > 2006-09-22 02:07:06.76 spid11s High priority system task thread:
>> >> > Operating system error Exception 0xAE encountered.
>> >> >
>> >> > in my log and it has grown enormous. What is causing this, how can I
>> >> > stop
>> >> > it
>> >> > and how can i cut my log file out so i can keep it running until we
>> >> > find a
>> >> > solution?
>> >> >
>> >> > Bryan
>> >>
>> >>
>> >>
>>

Error: 16955, Severity: 16, State: 2

When I used sql profiler to trace exception error of my sql server, I got a
bunch of error 16945,16955 and 208, I wonder if anyone knows how could I
locate where the error raised?
Thanks.Check if the article at
http://support.microsoft.com/default.aspx?scid=kb;en-us;302477 applies to
your case.
--
Dejan Sarka, SQL Server MVP
FAQ from Neil & others at: http://www.sqlserverfaq.com
Please reply only to the newsgroups.
PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org
"davidw" <wyx1999@.hotmail.com> wrote in message
news:OA#1t6xVDHA.2100@.TK2MSFTNGP11.phx.gbl...
> When I used sql profiler to trace exception error of my sql server, I got
a
> bunch of error 16945,16955 and 208, I wonder if anyone knows how could I
> locate where the error raised?
> Thanks.
>

Wednesday, March 7, 2012

Error with SMO.TransferData() (Exception from HRESULT: 0xC0011008)

OK, I have tried just about everything over the past 9 hours. I think I've read through every forum regarding anything similar to errors with SMO and TransferData().

However, I still can't fix my problem.

What I'm trying to accomplish is a workaround for deploying my database application using ClickOnce. Since I can't include the database when upgrading (which would wipe out users' data), I want to have a 'Master Database' that is used as a reference to both initially create, and to selectively update, the main 'User Database'. I'm not sure if that is possible, yet...because SMO is not working for me (I'm sure there are more laborious methods to do what I want, but SMO should work...I can't help but think there is a bug).

Here is my current code:

Code Snippet

'Master Database

Dim dbName_Master As String

Dim SqlCon_Master As SqlClient.SqlConnection = New SqlClient.SqlConnection(My.Settings.LM_Master_SQLConStr)

SqlCon_Master.Open()

dbName_Master = SqlCon_Master.Database.ToString()

Dim SC As New ServerConnection(SqlCon_Master)

Dim srv As New Smo.Server(SC)

'Verify User Instance connection

Console.WriteLine("User Instance Server: " & srv.InstanceName.ToString)

'Select the Master Database as the source db

Dim dbMaster As Smo.Database

dbMaster = srv.Databases(dbName_Master)

'Define a Transfer object and set the required options and properties.

Dim xfr As Smo.Transfer

xfr = New Smo.Transfer(dbMaster)

xfr.CopyAllObjects = True

xfr.CopyAllUsers = True

xfr.CopyData = True

xfr.CreateTargetDatabase = True

xfr.DropDestinationObjectsFirst = True

xfr.DestinationDatabase = "TestDB"

xfr.DestinationServer = srv.Name

xfr.DestinationLoginSecure = True

xfr.CopySchema = True

xfr.Options.WithDependencies = True

xfr.Options.ContinueScriptingOnError = True

xfr.Options.NoIdentities = False

xfr.Options.NoCollation = True

xfr.Options.Indexes = True

xfr.CopyAllDefaults = True

xfr.Options.AllowSystemObjects = True

xfr.Options.DriAll = True

xfr.Options.XmlIndexes = True

'Script the transfer. Alternatively perform immediate data transfer with TransferData method.

Dim StrColl As New System.Collections.Specialized.StringCollection

StrColl = xfr.ScriptTransfer()

For Each str As String In StrColl

Console.WriteLine(str)

Next

xfr.TransferData()

The final error is:

*****

DtsRuntimeException was unhandled...

Exception from HRESULT: 0xC0011008

*****

I also have not seen any examples or documentation on how to store the new database in a specific location on the hard drive, once the transfer is complete.

In fact, SMO has surprisingly little documentation that I can find (which is why the code above may seem a little redundant when setting the xfr options...). I would really appreciate some help.

Thank you,

AL

Try to set the connection up mannually. So instead of using the connection string:

Dim SqlCon_Master As SqlClient.SqlConnection = New SqlClient.SqlConnection(My.Settings.LM_Master_SQLConStr)

Use the server.(Parameters) such as userid, password, ect.

I ran into the same issue a while back with the transfer, once I set my connection parameters to my server manually this corrected the problem.

Here is an example in c# that I wrote maybe it will help. The vb conversion should be straightforward:

Code Snippet


//Two Server SMO objects to hold source and destination
Server server;
Server Source;

try
{
//Cannot use the SqlConnection class as this locks out DTO from accessing the login method.
//It appears DTO needs to be able to set the login properties which the SqlConnection locks it
//out of doing. Below commented methods will not work in this instance.
//SqlConnection conn = new SqlConnection("Data Source=.\sqlserver;integrated security = true");
//Server server = new Server(new ServerConnection(conn));

//Destination DataBase connected in an SMO manner using serverconnection
ServerConnection connec = new ServerConnection(".\SqlServer");
//Set secure login
connec.LoginSecure = true;
server = new Server(connec);
//Create target database. Transfer method does contain a create command but have not figured
//out how to get this to work. Easier to use the SMO method at this time.
Database dbo =new Database(server,"AdventureWorksClone");
dbo.Create();

//Source Database connected in an SMO manner using serverconnection
ServerConnection conn = new ServerConnection(".\SQLServer");
//Set secure login
conn.LoginSecure = true;
Source = new Server(conn);
//Set source to existing database that is to be copied
Database db = Source.Databases["AdventureWorks"];

//Establish transfer passing in source database
Transfer t = new Transfer(db);
t.CopyAllObjects = true;
t.DropDestinationObjectsFirst = true;
t.CopySchema = true;
t.CopyData = true;
//Don't know if this is still needed as it has been set in an SMO manner
t.DestinationLoginSecure = true;
//Destination Server created above
t.DestinationServer = server.Name;
//Could not get this to work yet
//t.CreateTargetDatabase = true;
//Newly created database on destination - Clone not quite right word as in ADO uses clone
//to indicate copying of schema only - not the case here
t.DestinationDatabase = "AdventureWorksClone";
t.Options.IncludeIfNotExists = true;
//This will copy all of the data and relations
//Alternatively could use t.scripttransfer() to copy just the schema
//SqlBulkCopy might be faster but might not make a copy of entire database
t.TransferData();

//Release server objects
server = null;
Source = null;

//Give verification that code is complete
Console.WriteLine("Executed");
Console.ReadLine();
}
catch (Exception ex)
{
Console.Out.WriteLine(ex);
Console.ReadLine();
server = null;
Source = null;
}

}
}

Hope this helps a little, sorry the code is in c#.

Aaron
|||

SMO uses SSIS under the covers to perform the workflow and data transfer pieces, here is what the error number means:

"Error loading from XML. No further detailed error information can be specified for this problem because no Events object was passed where detailed error information can be stored."

IIRC SMO generates an XML file on the fly that represents the package, is your temp environment variable set correctly? No probs with disk space etc?

|||Euan,
I recieved the same error when testing the code listed above but could not trace it. As soon as I switched my server connection method it worked without a hitch( I think I mention this in the sample.) so I do not know if this is as clear cut.
|||This is a little strange and i can not repo so I sent mail to the PM/Arch for SMO to see what he has to say.|||

Thank you for the example, Aaron. However, it did not work. Please note that I cannot connect to the default instance of SQL Server (also note that I only have SQL Express installed). I did try to apply your approach as best I could considering that I need to connect to the User Instance of SQL Express running with my application:

Code Snippet

Dim srv As Smo.Server

Dim source As Smo.Server

'*******This is the code to determine the Master Database name, used in original code

Dim dbName_Master As String

Dim SqlCon_Master As SqlClient.SqlConnection = New SqlClient.SqlConnection(My.Settings.LM_Master_SQLConStr)

SqlCon_Master.Open()

dbName_Master = SqlCon_Master.Database.ToString()

'This did not help: SqlCon_Master.ChangeDatabase("master")

Console.WriteLine("Master DB Name: " & dbName_Master)

'*******

Dim srvCon As New ServerConnection(SqlCon_Master)

srv = New Smo.Server(srvCon)

''Verify User Instance connection

Console.WriteLine("User Instance Server: " & srv.InstanceName)

If srv.Databases.Contains("MasterDB_Copy") Then

srv.Databases("MasterDB_Copy").Drop()

End If

Dim newDB As New Smo.Database(srv, "MasterDB_Copy")

newDB.Create()

'Create connection to Source DB

Dim sourceCon As New ServerConnection(SqlCon_Master)

source = New Smo.Server(sourceCon)

''Verify User Instance connection

Console.WriteLine("User Instance Server: " & source.InstanceName)

Dim MasterDB As Smo.Database = source.Databases(dbName_Master)

Dim xfr As New Smo.Transfer(MasterDB)

xfr.CopyAllObjects = True

xfr.DropDestinationObjectsFirst = True

xfr.CopySchema = True

xfr.CopyData = True

xfr.DestinationServer = srv.Name

xfr.DestinationDatabase = newDB.Name

xfr.Options.IncludeIfNotExists = True

Try

xfr.TransferData()

Catch ex As Exception

Console.WriteLine("Error: " & ex.Message)

End Try

srv = Nothing

source = Nothing

I still get the same error upon reaching TransferData().

If it means anything to this thread, I am using SMO for Backup and Restore successfully...so some SMO functions are working on my machine.

Is there anything else I can try?

Thanks,

AL

|||

Something I just tested:

I created a very simple test database, containing 2 tables; each table contains 2 columns. No relationships, constraints, or anything else. Just 2 tables with 2 columns each. I then changed the connection string to the new test database connection string.

I did this to determine if my Master Database is causing a problem for some reason, but I got the same error with the basic test database as I got with the more complex database.

So, the hunt for a solution continues...

|||You still are using a sqlconnection to initialize your server. Try initializing the the server with just the server instance name. Don't use the SqlClient to establish the server.

Code Snippet

Dim srvCon As New ServerConnection("ServerName")

'IE (".\SqlServer")

srvCon.LoginSecure = true;

'What ever other login properties set similar to above.

srv = New Smo.Server(srvCon)


When I replaced the sqlconnection with a direct server connection setting the connection properties manually with the ServerConnection I was able to transfer. There might be another issue, but I would definately try this first as this is the same issue I was having.

Aaron

|||

Okay, I have tried your method, Aaron (properly, this time...I think):

However, once again, it did not work...I could not connect to the server when trying to connect to the database directly. Your method, if it worked for me, would also imply that I cannot use SMO to transfer a database when I am using a user instance--there doesn't seem to be a User Instance option when creating the server connection (as I did below). Please look at the debugging information (comments) I provided in the Code Snippet below for details on what I tried to do:

Code Snippet

Dim srv As Smo.Server

Dim source As Smo.Server

'The connection string (auto-generated by Visual Studio):

' Data Source=.\SQLEXPRESS;AttachDbFilename="|DataDirectory|\LM_SQL.mdf";Integrated Security=True;Connect Timeout=20;User Instance=True

Dim sourceCon As New ServerConnection(".\SQLEXPRESS")

sourceCon.LoginSecure = True

'sourceCon.DatabaseName = My.Application.Info.DirectoryPath & "\LM_TestDB.mdf"

'My debugging information:

' ***I was able to connect to SQLEXPRESS when I didn't set the DatabaseName

' ***When I tried to use the above DatabaseName (which is in My Documents...Debug Folder), I got the error ArgumentException was unhandled..."The value's length for key 'initial catalog' exceeds it's limit of '128'."

'sourceCon.DatabaseName = "C:\Test\LM_TestDB.mdf"

' ***When I copied LM_TestDB.mdf (and ..._log.mdf) to a folder on the system drive (as shown right above this line), then set the DatabaseName to that file, I got the error "Failed to connect..."

' ***There doesn't seem to be a way to create a user instance when using the method above.

' ***Either way, I cannot connect to the server when I set the DatabaseName to a file...but what if I use the Database Name created when setting the test connection:

'sourceCon.DatabaseName = dbName_Master

' ***That did not work either.

sourceCon.ConnectTimeout = 30

sourceCon.Connect()

source = New Smo.Server(sourceCon)

'Verify database connection (NOT User Instance)

Console.WriteLine("Server Instance Name: " & source.InstanceName)

'More debugging:

' ***Now, I'll try to attach a database to the newly created server

Dim dbFilePathString As New System.Collections.Specialized.StringCollection()

'dbFilePathString.Add(My.Application.Info.DirectoryPath & "\LM_TestDB.mdf")

'dbFilePathString.Add(My.Application.Info.DirectoryPath & "\LM_TestDB_log.ldf")

' ***The file paths above did not work (Error: "Attach database failed for Server '[MyPCName]\SQLEXPRESS'."); now, I'll try the path to the DB in the test folder

dbFilePathString.Add("C:\Test\LM_TestDB.mdf")

dbFilePathString.Add("C:\Test\LM_TestDB_log.ldf")

' ***The file paths above worked, and the database was successfully added (as shown by the test below--all test tables were present in the console upon running)--but... (please scroll down to the next comment)

If source.Databases.Contains("TestDB") Then

source.DetachDatabase("TestDB", True)

End If

source.AttachDatabase("TestDB", dbFilePathString)

For Each db As Smo.Database In source.Databases

If db.Name = "TestDB" Then

Console.WriteLine("DB Name: " & db.Name)

Console.WriteLine("***")

Console.WriteLine("TestDB Found!")

Console.WriteLine("***")

For Each tbl As Smo.Table In db.Tables

Console.WriteLine(tbl.Name)

Next

Console.WriteLine("***End TestDB Tables***")

End If

Next

' ***I would not be able to use this method of connecting to the database because, with a ClickOnce install, the database files are stored in the users' Docs & Settings folders...which would make the file names too long for the purposes of attaching a database. The user would require administrative rights if my program tried to copy a file to anywhere but their Docs and Settings...considering the intended users of my application, that would not be a viable option.

Dim srvCon As New ServerConnection(".\SQLEXPRESS")

srvCon.LoginSecure = True

srvCon.ConnectTimeout = 30

srvCon.Connect()

srv = New Smo.Server(srvCon)

Dim newDB As New Smo.Database(srv, "TestDB_Copy")

If srv.Databases.Contains(newDB.Name) Then

srv.Databases(newDB.Name).Drop()

End If

newDB.Create()

Dim MasterDB As Smo.Database = source.Databases("TestDB")

Dim xfr As New Smo.Transfer(MasterDB)

xfr.CopyAllObjects = True

xfr.CopySchema = True

xfr.CopyData = True

xfr.DestinationServer = srv.Name

xfr.DestinationDatabase = newDB.Name

xfr.CreateTargetDatabase = True

xfr.DropDestinationObjectsFirst = True

xfr.Options.IncludeIfNotExists = True

xfr.TargetDatabaseFilePath = "C:\Test\CopyOfTestDB.mdf"

xfr.TargetLogFilePath = "C:\Test\CopyOfTestDB_log.ldf"

Try

xfr.TransferData()

Catch ex As Exception

Console.WriteLine("Error: " & ex.Message)

End Try

' ***I still got the same error, despite all the extra work of creating the connection to the database using the method above.

srv = Nothing

source = Nothing

The conclusion:

Aaron, your method will not work for my purposes. I will require a User Instance connection to SQL Server Express (it seems like User Instances are the only way to connect to a database stored a couple folder levels in the C: drive), and your method of connecting to the server and attaching a database does not work for my purposes will not work.

Also (and this is very important), I still got the same "Exception from HRESULT: 0xC0011008" error.

So, on to more ideas (hopefully).... Thank you for your help so far, Aaron.

|||

Hi Euan,

As you can see from the thread, Aaron's suggestion did not solve my problem. Have you heard anything yet from the PM/Arch for SMO?

Thanks,

AL

|||ALight,
Sorry about that, I thought the problem was something different. Did you ever get a solution?
|||

Sorry it took so long to respong, Aaron. No, I never found a solution to the problem. I'm guessing that SMO.Transfer simply will not work with User Instance server connections or databases.

However, I did find a better way, and probably one of the few ways, with ClickOnce/SQL Server Express apps:

Use build scripts to create and update the database. The information that I used was found in this White Paper:

http://msdn2.microsoft.com/en-us/library/bb264562.aspx

Scroll halfway down to the section entitled "Updating ClickOnce Deployments that Use SQL Server Express".

Certainly not as easy as SMO, but that will work.

Thanks for your help.

Andre

Error with SMO.TransferData() (Exception from HRESULT: 0xC0011008)

OK, I have tried just about everything over the past 9 hours. I think I've read through every forum regarding anything similar to errors with SMO and TransferData().

However, I still can't fix my problem.

What I'm trying to accomplish is a workaround for deploying my database application using ClickOnce. Since I can't include the database when upgrading (which would wipe out users' data), I want to have a 'Master Database' that is used as a reference to both initially create, and to selectively update, the main 'User Database'. I'm not sure if that is possible, yet...because SMO is not working for me (I'm sure there are more laborious methods to do what I want, but SMO should work...I can't help but think there is a bug).

Here is my current code:

Code Snippet

'Master Database

Dim dbName_Master As String

Dim SqlCon_Master As SqlClient.SqlConnection = New SqlClient.SqlConnection(My.Settings.LM_Master_SQLConStr)

SqlCon_Master.Open()

dbName_Master = SqlCon_Master.Database.ToString()

Dim SC As New ServerConnection(SqlCon_Master)

Dim srv As New Smo.Server(SC)

'Verify User Instance connection

Console.WriteLine("User Instance Server: " & srv.InstanceName.ToString)

'Select the Master Database as the source db

Dim dbMaster As Smo.Database

dbMaster = srv.Databases(dbName_Master)

'Define a Transfer object and set the required options and properties.

Dim xfr As Smo.Transfer

xfr = New Smo.Transfer(dbMaster)

xfr.CopyAllObjects = True

xfr.CopyAllUsers = True

xfr.CopyData = True

xfr.CreateTargetDatabase = True

xfr.DropDestinationObjectsFirst = True

xfr.DestinationDatabase = "TestDB"

xfr.DestinationServer = srv.Name

xfr.DestinationLoginSecure = True

xfr.CopySchema = True

xfr.Options.WithDependencies = True

xfr.Options.ContinueScriptingOnError = True

xfr.Options.NoIdentities = False

xfr.Options.NoCollation = True

xfr.Options.Indexes = True

xfr.CopyAllDefaults = True

xfr.Options.AllowSystemObjects = True

xfr.Options.DriAll = True

xfr.Options.XmlIndexes = True

'Script the transfer. Alternatively perform immediate data transfer with TransferData method.

Dim StrColl As New System.Collections.Specialized.StringCollection

StrColl = xfr.ScriptTransfer()

For Each str As String In StrColl

Console.WriteLine(str)

Next

xfr.TransferData()

The final error is:

*****

DtsRuntimeException was unhandled...

Exception from HRESULT: 0xC0011008

*****

I also have not seen any examples or documentation on how to store the new database in a specific location on the hard drive, once the transfer is complete.

In fact, SMO has surprisingly little documentation that I can find (which is why the code above may seem a little redundant when setting the xfr options...). I would really appreciate some help.

Thank you,

AL

Try to set the connection up mannually. So instead of using the connection string:

Dim SqlCon_Master As SqlClient.SqlConnection = New SqlClient.SqlConnection(My.Settings.LM_Master_SQLConStr)

Use the server.(Parameters) such as userid, password, ect.

I ran into the same issue a while back with the transfer, once I set my connection parameters to my server manually this corrected the problem.

Here is an example in c# that I wrote maybe it will help. The vb conversion should be straightforward:

Code Snippet


//Two Server SMO objects to hold source and destination
Server server;
Server Source;

try
{
//Cannot use the SqlConnection class as this locks out DTO from accessing the login method.
//It appears DTO needs to be able to set the login properties which the SqlConnection locks it
//out of doing. Below commented methods will not work in this instance.
//SqlConnection conn = new SqlConnection("Data Source=.\sqlserver;integrated security = true");
//Server server = new Server(new ServerConnection(conn));

//Destination DataBase connected in an SMO manner using serverconnection
ServerConnection connec = new ServerConnection(".\SqlServer");
//Set secure login
connec.LoginSecure = true;
server = new Server(connec);
//Create target database. Transfer method does contain a create command but have not figured
//out how to get this to work. Easier to use the SMO method at this time.
Database dbo =new Database(server,"AdventureWorksClone");
dbo.Create();

//Source Database connected in an SMO manner using serverconnection
ServerConnection conn = new ServerConnection(".\SQLServer");
//Set secure login
conn.LoginSecure = true;
Source = new Server(conn);
//Set source to existing database that is to be copied
Database db = Source.Databases["AdventureWorks"];

//Establish transfer passing in source database
Transfer t = new Transfer(db);
t.CopyAllObjects = true;
t.DropDestinationObjectsFirst = true;
t.CopySchema = true;
t.CopyData = true;
//Don't know if this is still needed as it has been set in an SMO manner
t.DestinationLoginSecure = true;
//Destination Server created above
t.DestinationServer = server.Name;
//Could not get this to work yet
//t.CreateTargetDatabase = true;
//Newly created database on destination - Clone not quite right word as in ADO uses clone
//to indicate copying of schema only - not the case here
t.DestinationDatabase = "AdventureWorksClone";
t.Options.IncludeIfNotExists = true;
//This will copy all of the data and relations
//Alternatively could use t.scripttransfer() to copy just the schema
//SqlBulkCopy might be faster but might not make a copy of entire database
t.TransferData();

//Release server objects
server = null;
Source = null;

//Give verification that code is complete
Console.WriteLine("Executed");
Console.ReadLine();
}
catch (Exception ex)
{
Console.Out.WriteLine(ex);
Console.ReadLine();
server = null;
Source = null;
}

}
}

Hope this helps a little, sorry the code is in c#.

Aaron
|||

SMO uses SSIS under the covers to perform the workflow and data transfer pieces, here is what the error number means:

"Error loading from XML. No further detailed error information can be specified for this problem because no Events object was passed where detailed error information can be stored."

IIRC SMO generates an XML file on the fly that represents the package, is your temp environment variable set correctly? No probs with disk space etc?

|||Euan,
I recieved the same error when testing the code listed above but could not trace it. As soon as I switched my server connection method it worked without a hitch( I think I mention this in the sample.) so I do not know if this is as clear cut.
|||This is a little strange and i can not repo so I sent mail to the PM/Arch for SMO to see what he has to say.|||

Thank you for the example, Aaron. However, it did not work. Please note that I cannot connect to the default instance of SQL Server (also note that I only have SQL Express installed). I did try to apply your approach as best I could considering that I need to connect to the User Instance of SQL Express running with my application:

Code Snippet

Dim srv As Smo.Server

Dim source As Smo.Server

'*******This is the code to determine the Master Database name, used in original code

Dim dbName_Master As String

Dim SqlCon_Master As SqlClient.SqlConnection = New SqlClient.SqlConnection(My.Settings.LM_Master_SQLConStr)

SqlCon_Master.Open()

dbName_Master = SqlCon_Master.Database.ToString()

'This did not help: SqlCon_Master.ChangeDatabase("master")

Console.WriteLine("Master DB Name: " & dbName_Master)

'*******

Dim srvCon As New ServerConnection(SqlCon_Master)

srv = New Smo.Server(srvCon)

''Verify User Instance connection

Console.WriteLine("User Instance Server: " & srv.InstanceName)

If srv.Databases.Contains("MasterDB_Copy") Then

srv.Databases("MasterDB_Copy").Drop()

End If

Dim newDB As New Smo.Database(srv, "MasterDB_Copy")

newDB.Create()

'Create connection to Source DB

Dim sourceCon As New ServerConnection(SqlCon_Master)

source = New Smo.Server(sourceCon)

''Verify User Instance connection

Console.WriteLine("User Instance Server: " & source.InstanceName)

Dim MasterDB As Smo.Database = source.Databases(dbName_Master)

Dim xfr As New Smo.Transfer(MasterDB)

xfr.CopyAllObjects = True

xfr.DropDestinationObjectsFirst = True

xfr.CopySchema = True

xfr.CopyData = True

xfr.DestinationServer = srv.Name

xfr.DestinationDatabase = newDB.Name

xfr.Options.IncludeIfNotExists = True

Try

xfr.TransferData()

Catch ex As Exception

Console.WriteLine("Error: " & ex.Message)

End Try

srv = Nothing

source = Nothing

I still get the same error upon reaching TransferData().

If it means anything to this thread, I am using SMO for Backup and Restore successfully...so some SMO functions are working on my machine.

Is there anything else I can try?

Thanks,

AL

|||

Something I just tested:

I created a very simple test database, containing 2 tables; each table contains 2 columns. No relationships, constraints, or anything else. Just 2 tables with 2 columns each. I then changed the connection string to the new test database connection string.

I did this to determine if my Master Database is causing a problem for some reason, but I got the same error with the basic test database as I got with the more complex database.

So, the hunt for a solution continues...

|||You still are using a sqlconnection to initialize your server. Try initializing the the server with just the server instance name. Don't use the SqlClient to establish the server.

Code Snippet

Dim srvCon As New ServerConnection("ServerName")

'IE (".\SqlServer")

srvCon.LoginSecure = true;

'What ever other login properties set similar to above.

srv = New Smo.Server(srvCon)


When I replaced the sqlconnection with a direct server connection setting the connection properties manually with the ServerConnection I was able to transfer. There might be another issue, but I would definately try this first as this is the same issue I was having.

Aaron

|||

Okay, I have tried your method, Aaron (properly, this time...I think):

However, once again, it did not work...I could not connect to the server when trying to connect to the database directly. Your method, if it worked for me, would also imply that I cannot use SMO to transfer a database when I am using a user instance--there doesn't seem to be a User Instance option when creating the server connection (as I did below). Please look at the debugging information (comments) I provided in the Code Snippet below for details on what I tried to do:

Code Snippet

Dim srv As Smo.Server

Dim source As Smo.Server

'The connection string (auto-generated by Visual Studio):

' Data Source=.\SQLEXPRESS;AttachDbFilename="|DataDirectory|\LM_SQL.mdf";Integrated Security=True;Connect Timeout=20;User Instance=True

Dim sourceCon As New ServerConnection(".\SQLEXPRESS")

sourceCon.LoginSecure = True

'sourceCon.DatabaseName = My.Application.Info.DirectoryPath & "\LM_TestDB.mdf"

'My debugging information:

' ***I was able to connect to SQLEXPRESS when I didn't set the DatabaseName

' ***When I tried to use the above DatabaseName (which is in My Documents...Debug Folder), I got the error ArgumentException was unhandled..."The value's length for key 'initial catalog' exceeds it's limit of '128'."

'sourceCon.DatabaseName = "C:\Test\LM_TestDB.mdf"

' ***When I copied LM_TestDB.mdf (and ..._log.mdf) to a folder on the system drive (as shown right above this line), then set the DatabaseName to that file, I got the error "Failed to connect..."

' ***There doesn't seem to be a way to create a user instance when using the method above.

' ***Either way, I cannot connect to the server when I set the DatabaseName to a file...but what if I use the Database Name created when setting the test connection:

'sourceCon.DatabaseName = dbName_Master

' ***That did not work either.

sourceCon.ConnectTimeout = 30

sourceCon.Connect()

source = New Smo.Server(sourceCon)

'Verify database connection (NOT User Instance)

Console.WriteLine("Server Instance Name: " & source.InstanceName)

'More debugging:

' ***Now, I'll try to attach a database to the newly created server

Dim dbFilePathString As New System.Collections.Specialized.StringCollection()

'dbFilePathString.Add(My.Application.Info.DirectoryPath & "\LM_TestDB.mdf")

'dbFilePathString.Add(My.Application.Info.DirectoryPath & "\LM_TestDB_log.ldf")

' ***The file paths above did not work (Error: "Attach database failed for Server '[MyPCName]\SQLEXPRESS'."); now, I'll try the path to the DB in the test folder

dbFilePathString.Add("C:\Test\LM_TestDB.mdf")

dbFilePathString.Add("C:\Test\LM_TestDB_log.ldf")

' ***The file paths above worked, and the database was successfully added (as shown by the test below--all test tables were present in the console upon running)--but... (please scroll down to the next comment)

If source.Databases.Contains("TestDB") Then

source.DetachDatabase("TestDB", True)

End If

source.AttachDatabase("TestDB", dbFilePathString)

For Each db As Smo.Database In source.Databases

If db.Name = "TestDB" Then

Console.WriteLine("DB Name: " & db.Name)

Console.WriteLine("***")

Console.WriteLine("TestDB Found!")

Console.WriteLine("***")

For Each tbl As Smo.Table In db.Tables

Console.WriteLine(tbl.Name)

Next

Console.WriteLine("***End TestDB Tables***")

End If

Next

' ***I would not be able to use this method of connecting to the database because, with a ClickOnce install, the database files are stored in the users' Docs & Settings folders...which would make the file names too long for the purposes of attaching a database. The user would require administrative rights if my program tried to copy a file to anywhere but their Docs and Settings...considering the intended users of my application, that would not be a viable option.

Dim srvCon As New ServerConnection(".\SQLEXPRESS")

srvCon.LoginSecure = True

srvCon.ConnectTimeout = 30

srvCon.Connect()

srv = New Smo.Server(srvCon)

Dim newDB As New Smo.Database(srv, "TestDB_Copy")

If srv.Databases.Contains(newDB.Name) Then

srv.Databases(newDB.Name).Drop()

End If

newDB.Create()

Dim MasterDB As Smo.Database = source.Databases("TestDB")

Dim xfr As New Smo.Transfer(MasterDB)

xfr.CopyAllObjects = True

xfr.CopySchema = True

xfr.CopyData = True

xfr.DestinationServer = srv.Name

xfr.DestinationDatabase = newDB.Name

xfr.CreateTargetDatabase = True

xfr.DropDestinationObjectsFirst = True

xfr.Options.IncludeIfNotExists = True

xfr.TargetDatabaseFilePath = "C:\Test\CopyOfTestDB.mdf"

xfr.TargetLogFilePath = "C:\Test\CopyOfTestDB_log.ldf"

Try

xfr.TransferData()

Catch ex As Exception

Console.WriteLine("Error: " & ex.Message)

End Try

' ***I still got the same error, despite all the extra work of creating the connection to the database using the method above.

srv = Nothing

source = Nothing

The conclusion:

Aaron, your method will not work for my purposes. I will require a User Instance connection to SQL Server Express (it seems like User Instances are the only way to connect to a database stored a couple folder levels in the C: drive), and your method of connecting to the server and attaching a database does not work for my purposes will not work.

Also (and this is very important), I still got the same "Exception from HRESULT: 0xC0011008" error.

So, on to more ideas (hopefully).... Thank you for your help so far, Aaron.

|||

Hi Euan,

As you can see from the thread, Aaron's suggestion did not solve my problem. Have you heard anything yet from the PM/Arch for SMO?

Thanks,

AL

|||ALight,
Sorry about that, I thought the problem was something different. Did you ever get a solution?
|||

Sorry it took so long to respong, Aaron. No, I never found a solution to the problem. I'm guessing that SMO.Transfer simply will not work with User Instance server connections or databases.

However, I did find a better way, and probably one of the few ways, with ClickOnce/SQL Server Express apps:

Use build scripts to create and update the database. The information that I used was found in this White Paper:

http://msdn2.microsoft.com/en-us/library/bb264562.aspx

Scroll halfway down to the section entitled "Updating ClickOnce Deployments that Use SQL Server Express".

Certainly not as easy as SMO, but that will work.

Thanks for your help.

Andre

Sunday, February 26, 2012

Error with expoting to Excel

I got the following error when exporting a report to Excel
Reporting Services Error
----
Exception of type
Microsoft.ReportingServices.ReportRendering.ReportRenderingException was
thrown. (rrRenderingError) Get Online Help
Exception of type
Microsoft.ReportingServices.ReportRendering.ReportRenderingException was
thrown.
An unexpected error occurred in Report Processing. (rsInternalError) Get
Online Help
Object reference not set to an instance of an object
--
Amila IndikaI got the same error.
I have a table in report body and grouped by, say, ColA.
In the page footer, a textbox refererences ColA by
First(ReportItems!ColA.Value).
When I export the report in PDF format, it works fine, but I got the error
when exporting to EXCEL format.
Any solution? Thanks
"Amila Indika" wrote:
> I got the following error when exporting a report to Excel
> Reporting Services Error
> ----
> Exception of type
> Microsoft.ReportingServices.ReportRendering.ReportRenderingException was
> thrown. (rrRenderingError) Get Online Help
> Exception of type
> Microsoft.ReportingServices.ReportRendering.ReportRenderingException was
> thrown.
> An unexpected error occurred in Report Processing. (rsInternalError) Get
> Online Help
> Object reference not set to an instance of an object
> --
> Amila Indika
>

Sunday, February 19, 2012

error while previewing a report in Server Reporting Services

type initialization exception:The type initializer for microsoft.reportingservices.diagnostics.globals threw an exception
This is the exception i am getting while running a report in SSRS.Can anyone plz help me out with thi
From http://www.developmentnow.com/g/115_2005_4_0_28_0/sql-server-reporting-services.ht
Posted via DevelopmentNow.com Group
http://www.developmentnow.comHi
this error would come up.
if the datatype you are using in your parameters setting is not
correct.
or there is an incorrect assignment of value to a type.
Regards,
Sarang
On Mar 7, 10:34=A0am, Sadiq<nos...@.developmentnow.com> wrote:
> type initialization exception:The type initializer for microsoft.reporting=services.diagnostics.globals threw an exception
> This is the exception i am getting while running a report in SSRS.Can anyo=ne plz help me out with this
> Fromhttp://www.developmentnow.com/g/115_2005_4_0_28_0/sql-server-reportin.=
..
> Posted via DevelopmentNow.com Groupshttp://www.developmentnow.com