在VB.Net中创建系统DSN [英] Creating System DSN in VB.Net

查看:98
本文介绍了在VB.Net中创建系统DSN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个看起来像这样的代码,它将创建一个具有用户名和密码的系统dsn.它可以工作,但是当我查看创建的dsn时,登录ID和密码具有默认值.希望你能帮我..谢谢:)

I have a code that looks like this that will create a system dsn that has a username and password. It works but when i looked in my created dsn, the login id and password have default values. Hope you''ll help me guys.. thanks :)

Private Shared Sub CreateSystemDSN()
    'create dsn programmatically
    Dim ReturnValue As Integer
    Dim Driver As String
    Dim Attributes As String

    'Set the driver to SQL Server because it is most common.
    Driver = "SQL Server"
    'Set the attributes delimited by null.
    'See driver documentation for a complete
    'list of supported attributes.
    Attributes = "SERVER=" & dbServer & Chr(0)
    Attributes = Attributes & "DESCRIPTION=" & dbName & Chr(0)
    Attributes = Attributes & "DSN=" & dbName & Chr(0)
    Attributes = Attributes & "DATABASE=" & dbName & Chr(0)
'---> error part
    Attributes = Attributes & "TRUSTED_CONNECTION=NO" & Chr(0)
    Attributes = Attributes & "UID=" & dbUser & Chr(0)
    Attributes = Attributes & "PWD=" & dbPassword & Chr(0)
'---> end of error part
    'To show dialog, use Form1.Hwnd instead of vbAPINull.
    ReturnValue = SQLConfigDataSource(vbAPINull, ODBC_ADD_SYS_DSN, Driver, Attributes)
    If ReturnValue <> 0 Then
        MsgBox("DSN Created")
    Else
        MsgBox("Please contact administrator. ODBC Connection failed.")
    End If
End Sub

推荐答案



也许这会有所帮助

如何使用VB以编程方式为SQL Server创建DSN [


maybe this will help

How To Programmatically Create a DSN for SQL Server with VB[^]


这篇关于在VB.Net中创建系统DSN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆