ProgrammingMSAccess.com

Learn about Developers Group
Join Developers Group
Order SPAM Blocker
Free Stuff
Guest Book
.NET Resources
SQL Server Resources
Favorites
Technical Support
Books & DVDs by Webmaster
Articles, tutorials, & more
FAQs
Product Reviews
Samples
Prior Newsletters
Contact Us
Home
 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

This procedure demonstrates how to connect to a sql server database with a windows account.

Private Sub Button1_Click(ByVal sender As System.Object, _

ByVal e As System.EventArgs) Handles Button1.Click

 

'Declare, instantiate, and open a connection

Dim cnn1 As SqlClient.SqlConnection = _

New SqlClient.SqlConnection("Data Source=CCS1;" & _

    "Initial Catalog=HCVB;Integrated Security=SSPI")

Try

    cnn1.Open()

    MsgBox("Connection opened successfully.")

Catch ex1 As SqlClient.SqlException

    MsgBox(ex1.Message)

Finally

    cnn1.Close()

End Try

End Sub

 

Learn more about VB.NET programming from either Programming Microsoft SQL Server 2000 with Microsoft Visual Basic .NET or Programming Microsoft Visual Basic .NET for Microsoft Access Databases.

Copyright 2003 CAB, Inc. All rights reserved. Republication or redistribution of CAB, Inc. content, including by framing or similar means, is expressly prohibited without the prior written consent of CAB, Inc. CAB, Inc. shall not be liable for any errors in the content, or for any actions taken in reliance thereon.