How to write code for linked server in vb.net?

D

damezumari

I use winxp and microsoft visual basic net 2003.

I want to fill table a running a select query on tables in b.

a and b are in different databases on different sql servers.

csql = "select ... into a from <linkedserver>.<database>.dbo.b ..."
cmd = New SqlCommand(csql, cn)
***
iRowsAffected = cmd.ExecuteNonQuery()

I know I have to put some code where *** are.
In sql query analyser it looks like this:

sp_addlinkedserver @server = 'Dover'
sp_addlinkedsrvlogin @rmtsrvname = 'Dover', @useself = 'true',
@locallogin = 'jan', @rmtuser = NULL, @rmtpassword = NULL

How would I write these two commands in vbnet?

Grateful for any help!

Regards,

Jan Nordgreen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top