PC Review


Reply
Thread Tools Rate Thread

Copying tables in SQLEXPRESS

 
 
Michel Vanderbeke
Guest
Posts: n/a
 
      19th Aug 2007
Hello,

Thank you for your help.

When I browse the internet, I only find examples on how to restore an entire
database.
What I try to achieve is to replace only one or several tables in the
database by updated tables from another database.

I added the reference to Microsoft.SqlServer.Smo and to
Microsoft.sqlServer.ConnectionInfo to my project.

In an example, I found following code:
Dim svr As Server = New Server() '

Dim res As Restore = New Restore()

res.DeviceType = DeviceType.File

===> this line gives an ERROR: DeviceType is not a member of
Microsoft.SqlServer.Management.Smo.Restore

res.Devices.Add("C:\Kassasysteem\Kassasysteem.mdf")

===> this line gives an ERROR: Value of type 'String' cannot be converted
to Microsoft.SqlServer.Management.Smo.BackupDeviceItem

res.Database = "Kassasysteem"

res.ReplaceDatabase = True

res.PercentCompleteNotification = 10

AddHandler res.PercentComplete, AddressOf ProgressEventHandler

res.SqlRestore(svr)


Can you please help me to fix this errors and explain to me how I can
restore only a few tables from a database and not the entire database?

Many thanks,

Michel



>Yes, you can use SMO to achieve what you desire. (SQL Management Objects).
>You can also script out the DDL and run it.
>
>... provided the acount you are doing this under has sufficient privileges
>(both SMO or DDL).
>
>--
>Gregory A. Beamer
>MVP, MCP: +I, SE, SD, DBA
>
>*************************************************
> Think outside the box! |
>*************************************************


>>"Michel Vanderbeke" <(E-Mail Removed)> wrote in message
>>news:46c44d97$0$13859$(E-Mail Removed)...
>> Hello,
>>
>> I have a program, running in several places, using SQLEXPRESS as
>> database.
>> The different places are stand-alone, and not connected to a network.
>> Regulary, I have to apply changes on certain tables of the database.
>>
>> In a previous program, written in VB6 with an Access database, I used JRO
>> through VB6-code to delete the table in the different databases and to
>> copy
>> the new one.
>>
>> Is something similar possible with SQLEXPRESS. I would like to be able
>> to
>> update tables in an SQLEXPRESS database file by deleting them and replace
>> them with the new table. Is this possible through VB.NET code?
>>
>> Many thanks and greetings from Brugge (Bruges - Belgium),
>>
>> Michel



 
Reply With Quote
 
 
 
 
William Vaughn
Guest
Posts: n/a
 
      19th Aug 2007
Check out SqlBulkCopy

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant, Dad, Grandpa
Microsoft MVP
INETA Speaker
www.betav.com
www.betav.com/blog/billva
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

"Michel Vanderbeke" <(E-Mail Removed)> wrote in message
news:46c836a1$0$13862$(E-Mail Removed)...
> Hello,
>
> Thank you for your help.
>
> When I browse the internet, I only find examples on how to restore an
> entire database.
> What I try to achieve is to replace only one or several tables in the
> database by updated tables from another database.
>
> I added the reference to Microsoft.SqlServer.Smo and to
> Microsoft.sqlServer.ConnectionInfo to my project.
>
> In an example, I found following code:
> Dim svr As Server = New Server() '
>
> Dim res As Restore = New Restore()
>
> res.DeviceType = DeviceType.File
>
> ===> this line gives an ERROR: DeviceType is not a member of
> Microsoft.SqlServer.Management.Smo.Restore
>
> res.Devices.Add("C:\Kassasysteem\Kassasysteem.mdf")
>
> ===> this line gives an ERROR: Value of type 'String' cannot be converted
> to Microsoft.SqlServer.Management.Smo.BackupDeviceItem
>
> res.Database = "Kassasysteem"
>
> res.ReplaceDatabase = True
>
> res.PercentCompleteNotification = 10
>
> AddHandler res.PercentComplete, AddressOf ProgressEventHandler
>
> res.SqlRestore(svr)
>
>
> Can you please help me to fix this errors and explain to me how I can
> restore only a few tables from a database and not the entire database?
>
> Many thanks,
>
> Michel
>
>
>
>>Yes, you can use SMO to achieve what you desire. (SQL Management Objects).
>>You can also script out the DDL and run it.
>>
>>... provided the acount you are doing this under has sufficient privileges
>>(both SMO or DDL).
>>
>>--
>>Gregory A. Beamer
>>MVP, MCP: +I, SE, SD, DBA
>>
>>*************************************************
>> Think outside the box! |
>>*************************************************

>
>>>"Michel Vanderbeke" <(E-Mail Removed)> wrote in message
>>>news:46c44d97$0$13859$(E-Mail Removed)...
>>> Hello,
>>>
>>> I have a program, running in several places, using SQLEXPRESS as
>>> database.
>>> The different places are stand-alone, and not connected to a network.
>>> Regulary, I have to apply changes on certain tables of the database.
>>>
>>> In a previous program, written in VB6 with an Access database, I used
>>> JRO
>>> through VB6-code to delete the table in the different databases and to
>>> copy
>>> the new one.
>>>
>>> Is something similar possible with SQLEXPRESS. I would like to be able
>>> to
>>> update tables in an SQLEXPRESS database file by deleting them and
>>> replace
>>> them with the new table. Is this possible through VB.NET code?
>>>
>>> Many thanks and greetings from Brugge (Bruges - Belgium),
>>>
>>> Michel

>
>


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying tables in SQLEXPRESS Michel Vanderbeke Microsoft ADO .NET 3 17th Aug 2007 04:53 PM
Copying tables in SQLEXPRESS Michel Vanderbeke Microsoft VB .NET 2 17th Aug 2007 06:27 AM
linked tables with SQLEXPRESS all show #DELETED phil Microsoft Access 1 11th Feb 2007 10:12 AM
Copying tables using VBA =?Utf-8?B?T19kb2c=?= Microsoft Access VBA Modules 2 6th Apr 2005 12:13 AM
Copying Tables Mike Microsoft Access Forms 1 9th Jan 2004 04:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:36 AM.