dbTalk Databases Forums  

(un?) related question re:sp_droplinkedsrvlogin

microsoft.public.sqlserver.olap microsoft.public.sqlserver.olap


Discuss (un?) related question re:sp_droplinkedsrvlogin in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
David Macaskill
 
Posts: n/a

Default (un?) related question re:sp_droplinkedsrvlogin - 11-04-2003 , 01:52 PM






Hi all,

I'm trying to drive sp_droplinkedsrvlogin, sp_dropserver,
sp_addlinkedsrvlogin and sp_addlinkedserver programmatically (VB6.0,
ADO). I think I've got it working, but it's kinda gross. I'm
wondering if there's a clean up.

My specific question is how should I handle NULL parameters. Currently
I check the string arguments and if they're vbNullString I stick a
NULL in, instead of the value. I've checked the routines in
QueryAnalyzer (sp_helptext) and see the checks for null. As I said
this works, but there's probably a better way. Any ideas? Cheers. DEM

For example - this is what my DropLinkServer() code looks like:

Public Sub DropLinkedSrvLogin(rmtSvrName As String, localUser As
String, strConnect As String)
On Error GoTo ErrorHandler

Dim oCmd As ADODB.command
Dim strSQL As String

oCn.Open strConnect
oCn.BeginTrans

Set oCmd = New ADODB.command
With oCmd
.ActiveConnection = oCn
.CommandText = "sp_droplinkedsrvlogin"
.CommandType = adCmdStoredProc
.CommandTimeout = 15
.Parameters.Append .CreateParameter("returncode", adInteger,
adParamReturnValue)
.Parameters.Append .CreateParameter("@rmtsrvname", adVarWChar,
adParamInput, 128, rmtSvrName)

If Not localUser = vbNullString Then
.Parameters.Append .CreateParameter("@locallogin",
adVarWChar, adParamInput, 128, localUser)
Else
.Parameters.Append .CreateParameter("@locallogin",
adVarWChar, adParamInput, 128, Null)
End If
End With

On Error GoTo ErrorDoesNotExist
oCmd.Execute , , adExecuteNoRecords

Reply With Quote
Reply




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.