Click here to Skip to main content
14,695,505 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i can use following code but not work in VB.NET
Using System.Data.SqlClinet;

SqlConnection con;
SqlCommand cmd;
Updated 11-May-18 22:30pm

You are using C# Syntax.

Have a look at below link for VB.Net syntax.
Espen Harlinn 1-Nov-11 13:21pm
Nice link, my 5
[no name] 2-Nov-11 0:47am
Thank you Espen. :)

Dim con As New SqlConnection()
Dim cmd As New SqlCommand()
If you need help with connection strings, go to[^]. You can pick up the right database you are looking for.
using cn as new sqlconnection(ConnectionString)
end using


dim cn as new sqlconnection("ConnectionString")

Have a read of this article it will show you how to make a connection to a SQL Server database. MSDN: Sqlconnection[^]

This article will show you how to execute a command against the database using sqlcommand MSDN: Sqlcommand[^]
first line on you vb write this code
privatesub then
dim con as newsqlconnection ("server=name of yor computer or (.);database =name of you database then semicolon; integrated security= true")

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