Insert data using OleDbConnection Use ACE.OLEDB for databse connection (insert data) Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim con As New OleDbConnection(“Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Projects\Northwind.accdb;Persist Security Info=False”) Dim CmdStr As String = “insert into sample _ (emp_name,category,city) _ values (‘” & TextBox2.Text & “‘,_ ‘” & TextBox3.Text & “‘,_ ‘” & […]
Archive for the 'MS SQL' Category
Classic ASP Connection String
Sql connection ************************ Dim connStr connStr = “Provider=SQLOLEDB;Data Source=my-sql-server;UID=MyUsernmame; PWD=MyPassword; database=MyDatabase;” Set objConn = Server.CreateObject(“ADODB.Connection”) objConn.ConnectionTimeOut = 30 objConn.ConnectionString = connStr objConn.Open SET objRS = Server.CreateObject(“ADODB.RecordSet”) objRS.Open “SELECT * FROM my_table ORDER BY type asc”,objConn,1,2 ‘do some sql work objRS.Close SET objRS = Nothing Access 2007/2010 connection ************************ DIM objConn, objRS, dsn, dbPath dsn = […]
OleDbConnection string with ConfigurationManager
Web config <add name=”MyConnectionString” connectionString=”Data Source=SRV-MY-SQL\SQLCLSTR12; Initial Catalog=MyDatabaseName; Persist Security Info=True;User ID=MyUser;Password=MyPassword” providerName=”System.Data.SqlClient” /> Code behind or markup page ‘defines sql connection Dim connString As String connString = ConfigurationManager.ConnectionStrings(“MyConnectionString”).ToString Dim ConnDB As New OleDbConnection(“Provider=sqloledb;” & connString) ‘define oledbcommand Dim cmd As New OleDbCommand(“SELECT * _ “FROM my_table _ “WHERE name=’Mike’ ;”, ConnDB) Dim reader As […]