Thursday, September 9, 2010

VB.NET Web.Config File with ConnectionString


//For Access
//Imports System.Data.Oledb

Dim cmd As New OleDbCommand
Dim cnmdb As OleDbConnection = New OleDbConnection(ConfigurationSettings.AppSettings("ConnectionStringmdb"))
cnmdb.Open()
cmd = New OleDbCommand("insert into mainmaster values('" & txtname.Text & " ','" & txtcontact.Text & "','" & txtbilladd.Text & "',)", cnmdb)

cmd.ExecuteNonQuery()

//For Sqlserver
//Imports System.Data.Sqlclient

Dim cmd As New SqlCommand
Dim cn As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
cn.Open()
cmd = New SqlCommand("insert into mainmaster values('" & txtname.Text & " ','" & txtcontact.Text & "','" & txtbilladd.Text & "',)", cn)

cmd.ExecuteNonQuery()


No comments: