使用智能设备和Visual Basic的sql server 2008的连接字符串

时间:2013-11-15 17:39:46

标签: sql-server

在Visual Basic 2008上为智能设备做一个小应用程序,我已经创建了一个模块来控制链接到常规表单的连接,在模块内部我已经声明了我的连接字符串但是没有工作。< / p>

声明如下:

Public conn As New SqlConnection("Data Source=myServer;Initial Catalog=myDataBase;Integrated Security=SSPI")

用于尝试连接的小子例程:

Public Sub connect()
    Try
        conn.Open()
        Form1.lblmensajes1.Text = "CONNECTED..."
    Catch ex As Exception
         Form1.lblmensajes1.Text = "NOT CONNECTED"
         Form1.TextBox1.Text = ex.ToString

    End Try
 End Sub

例外:

System.Data.SqlClient.SqlConnection.OnError(SqlException exception, TdsParserState state) 
    System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, TdsParserState state)
    System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
     System.Data.SqlClient.TdsParser.Connect(String host, SqlInternalConnection connHandler, Int32 timeout) 
     System.Data.SqlClient.SqlInternalConnection.OpenAndLogin()
     System.Data.SqlClient.SqlInternalConnection..ctor(SqlConnection connection, Hashtable connectionOptions)
     System.Data.SqlClient.SqlConnection.Open() en SmartDeviceProject1.conection.connect() 
    SmartDeviceProject1.Form1.btnconect_Click(Object sender, EventArgs e)
    System.Windows.Forms.Control.OnClick(EventArgs e)
    System.Windows.Forms.Button.OnClick(EventArgs e)

System.Windows.Forms.ButtonBase.WnProc(WM wm, Int32 wParam, Int32 lParam) 
System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)
 Microsoft.AGL.Forms.EVL.EnterMainLoop(IntPtr hwnMain)
 System.Windows.Forms.Application.Run(Form fm)
 SmartDeviceProject1.Form1.Main()

1 个答案:

答案 0 :(得分:0)

http://www.connectionstrings.com/

精简版

Data Source = myServerAddress; Initial Catalog = myDataBase; Integrated Security = SSPI; 用户ID = myDomain \ myUsername;密码= myPassword;