Hi guys..
Please guide me for the database connectivity with sql server express edition 2005 for any website.

A simple code on how to connect sql 2005 from VB.Net or ASP.Net via SQL connection string, and the use of ExecuteNonQuery()

method to execute the command and the try and catch to catch errors during runtime.

Example information:

SQL data:

Database name: user

Table name: user_t

Columns: user_id,lname,fname,username,password,usertype



textID = for Id

textlname = for last name

textfname = for first name

textusername = for user name

textpassword = for password


comboUsertype = for user type


Dim con As New SqlClient.SqlConnection

Dim strCon as string = "Data Source=Admin\SQLEXPRESS;Initial Catalog=user;Integrated Security=True"

Dim strCommand as string = “Insert into user_t (user_id, lname, fname, username, password, usertype) values ('”&

me.textID.text &”','” & me.textlname.text &”', '” &me.fname.text &”', '”&me.textusername.text &”','”& me.textpassword.text

&”','”&me.comboUsertype.text &”')”

Sub insert()

con.ConnectionString = strCon

Dim cm As New SqlClient.SqlCommand(strCommand, con)



MsgBox("Succesfully saved…")


End sub

This article has been dead for over six months. Start a new discussion instead.