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 = […]
Archive for the 'SQL' Tag
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 […]
Array – using array (vb.net) to update multiple records
‘Dim RecIDRE As String = Request.Form(“reId”) If Not RecID = 0 Then Try ‘define sql conn Dim connString As String connString = ConfigurationManager.ConnectionStrings(“MySQLConnectionString1”).ToString Dim conn As New SqlConnection(connString) Dim cmd As New SqlCommand() conn.ConnectionString = connString conn.Open() Dim printArray As Array = RecID.Split(“,”) Dim i As Integer For i = 0 To printArray.Length – 1 […]