Click here to Skip to main content
15,908,901 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am an experienced VB6 user and have read from and written to SQL databases many times from VB6 code but I am struggling to find the VB.NET equivalents. I used ADO with VB6. I presume I use ODBC with VB.NET as ADO is not (apparently) supported. Do you have any code examples which perform these functions?
Posted
Comments
[no name] 11-Jul-12 11:31am    
A bit old but should get you started, http://www.codeproject.com/Articles/8157/ADO-NET-101-SQL-Connection

It's ADO.NET with VB.NET/C# to read-write data.

Read about ADO.NET here and it will help you:
MSDN: ADO.NET[^]
MSDN: Accessing Data with ADO.NET[^]

CP archive:
Using ADO.NET for beginners[^]
Simple ADO.NET Database Read, Insert, Update and Delete using C#.[^]
 
Share this answer
 
Comments
Manas Bhardwaj 11-Jul-12 16:42pm    
Good +5!
Hi,

Here is a sample code to use sql database in vb.net

Create database using the server explorer tool in visual studio 2008 as

1. Right Click on Data Connection -> Add Connection
If the data source is 'Microsoft SQL Server Database File (SqlClient)'
then just type the database name and click OK

2. Just select the data base file and press F4 it sets focus to database properties
3. Copy the connection sting from properties.
4. Start doing as below,

Dim con As New SqlConnection("Past your connection string here")
dim cmd as sqlcommand
cmd=new sqlcommand("Select * from table_name", con)
'In the above statement I've enter the command text and connection property for the sql command
con.open()
cmd.executenonquery()
con.close()

That is all

Thank You,

Ganesh
 
Share this answer
 
v2

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