VBA Using SQL Codes

This is your employment contract amoxicillin 500mg dose for ear infection “One of the anxieties in the business community is that the so called ‘capital Taliban’ in the Bank of England are imposing restrictions which at this delicate stage of recovery actually make it more difficult for companies to operate and expand,” said Mr Cable. ruralhealth.org.au House Democrats journeyed to the White House to discuss the fiscal stalemate, and Senate Democrats and Republican leaders in the House of Representatives will make separate treks on Thursday amid rising worries about the potential for economic havoc in the crisis. maimonides medical center program internal medicine residency application â??Itâ??s like five Wendys [as in Williams] except we have five different opinions,â? adds Braxton. â??Itâ??s real like Steve Harvey, and itâ??s coming from a womanâ??s perspective, like â??The View.â?? â? elan pharma india pvt. ltd. mumbai maharashtra Prosecutors in his case said Mitts, who is white, is a racist who allowed two white people to flee unharmed before shooting Bryant, a black man, and that he used racial epithets throughout the police standoff. legal-anabolics.org Videgaray said the changes would bring Pemex into line withrules that govern other state-run oil companies like those inBrazil and Colombia, which have both successfully changed theirlumbering oil monopolies.

  Rupesh Kumar

I got below code to extract data from SQL server using VBA code:

Option Explicit

Const constrSQL As String = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=True;Data Source=LH7U05CG527243J\SQLEXPRESS2012;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=LH7U05CG527243J;Use Encryption for Data=False;Tag with column collation when possible=False;Initial Catalog=Mydatabase"

Sub copydatafromdatabase()

      Dim Mydatabaseconn As ADODB.Connection
      Dim Mydatabasedata As ADODB.Recordset
      Dim Mydatabasefield As ADODB.Field
      Set Mydatabaseconn = New ADODB.Connection
      Set Mydatabasedata = New ADODB.Recordset
      Mydatabaseconn.ConnectionString = constrSQL
      On Error GoTo closeconnection

    With Mydatabasedata
         .ActiveConnection = Mydatabaseconn
         .Source = "select * from employee_data"
         .LockType = adLockReadOnly
         .CursorType = adOpenForwardOnly
End With

On Error GoTo closerecordset


For Each Mydatabasefield In Mydatabasedata.Fields
         ActiveCell.Value = Mydatabasefield.Name
         ActiveCell.Offset(0, 1).Select
Next Mydatabasefield

Range("A2").CopyFromRecordset Mydatabasedata

On Error GoTo 0



End Sub

  Rupesh Kumar       15 Sep 2016       0       0     

Hi Rupesh,

is this code working for you?


  Devbrat Tripathi       16 Sep 2016       0       0     

Yes Dev....

  Rupesh Kumar       19 Sep 2016       0       0     

Post Your Answers:

Please use the CODE HIGHLIGHT Button to format/highlight your codes if any