Click here to Skip to main content
15,924,482 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys,

I already tried searching on google all day but it only gives me the result of vb.net to mysql or ms access. May i know how/where i can find tutorial about connecting vb.net windows application with ms sql server 2008 as backend? Thank in advance.
Posted

I don't know about a tutorial, but connection can be achieved following these instructions:

You need the next headers in every class you want to use connections or anything:
VB
Imports System.Data
Imports System.Data.SqlClient

You wil need a connection object, this comes from the aforementioned headers:
VB
Dim conn As New SqlConnection("your connection string here")


When you want to open the connection use conn.Open() and conn.Close() for the opposite.
Connection should be open when you issue commands to SQL Server. Never forget to close.

For more information regarding what your connection string should be, go to http://www.connectionstrings.com/sql-server/[^]

Most of the time the template of the connection string will be:
"Server=myServerAddress;Database=myDataBase;User Id=myUsername;
Password=myPassword;"

There are different commands to perform the different tasks you want on a database; sometimes you want to do an INSERT, DELETE or UPDATE, you may want to select a single value, or retrieve a table result set. These answers are out of the scope of this question, so I suggest you issue yet another question.
 
Share this answer
 
Comments
athan_makubex 28-Sep-13 22:07pm    
Thanks Homero! It helps me a lot.
On MSDN[^] site ;)
 
Share this answer
 
Try LinqtoSql, it is very easy!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900