hello,
my problem is how to make relation between Visual basic 2008.. and sql server 2005 .. i need some codes i think to make that .. but iam beginner ..Â
please anyone can help me
thankss
How to connect vb.Net 2008 with SQL server 2005
Â
Hey geraldine!
Â
Yes you are right, there are some codes that we need to do this work.
Â
For this purpose make sure that the project on which you are working has a reference to System.Data.SqlClient namespace.
Â
If you want to add the namespace follow these steps:
Â
1. Open your project.
Â
2. Here on the .NET tab, Add option of reference menu in Visual Basic.
Â
3. In the list find System.Data.SqlClient. Once find, select it and press OK.
Â
4.Now you have to add "import a statement" from the Declaration section. This statement is as follow
Â
Imports System.Data.SqlClient
Â
5. After, you have done all this, you are ready to make a relation between VB and SQL with the help of this code:
Â
Dim cn As New SQLConnection
' Set the connection string.
cn.ConnectionString = "SERVER=.SQLEXPRESS;Integrated Security=TRUE"
Try
' Open the connection.
cn.Open()
Catch ex As Exception
' Display error messages.
MessageBox.Show("Connection error: :" & ex.ToString())
End Try
' Close the connection.
cn.Close()
Thanks
Â