日期:2014-05-17  浏览次数:20989 次

在别人写的网站里发现这样一个链接方式,不太明白
'*******************************************************************************
'   函数功能:连接到master数据库
'*******************************************************************************
Function   GetMastercn(ByRef   conn)
dim   index1,   index2,   strConn
strConn   =   Application( "cn_ConnectionString ")
index1   =   instr(strConn,   "Initial   Catalog= ")
index2   =   instr(index1,   strConn,   "; ")
strConn   =   left(strConn,   index1   -   1)   &   "Initial   Catalog=master "   &   right(strConn,   len(strConn)   -   index2   +   1)
'on   error   resume   next
conn.Open   strConn
GetMastercn   =   CStr(Err.number)   &   Err.Description
Err.Clear
end   function
谁能告诉我这是怎么回事   怎么修改   如果我换数据库名   怎么办

------解决方案--------------------
实际上这就是连接数据库的函数,你可以输出Application( "cn_ConnectionString ") 与 strconn 看一下,就明白啦