Click here to Skip to main content
15,883,883 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;
Posted
Updated 11-May-18 21:30pm

You are using C# Syntax.

Have a look at below link for VB.Net syntax.
http://www.daniweb.com/software-development/vbnet/code/216920
 
Share this answer
 
v2
Comments
Espen Harlinn 1-Nov-11 13:21pm    
Nice link, my 5
RaisKazi 2-Nov-11 0:47am    
Thank you Espen. :)
Try

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


or

VB
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[^]
 
Share this answer
 
first line on you vb write this code
imports system.data.sqlclient
privatesub then
dim con as newsqlconnection ("server=name of yor computer or (.);database =name of you database then semicolon; integrated security= true")
then conn.open()
 
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