Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

About Importing Access Tables into Sql

Status
Not open for further replies.

drek01

MIS
Apr 1, 2007
87
US
Till of now i was using accee built in import method to import access table from ( access database) into sql server.However now i have to do it from my front end( that is access, Code in VBA).
or ,


I'm guessing that i need to establish a connection to the selected database, and then query a specific table, and load the contents into sql server.
 
Usually the easiest way is to build your target table and append to a link of it.
 
actually is it just possible to add table in your sql databse.
i donot know how that works.
help me out here.
 
can you give me idea about linking table.
 
i have file browser which opens access database and loads the tables into list box. now what i want to do is to select the tables and able to import it into sql server.

how do i do this. i found sample code in VB to import excel spreadsheet into sql server, can you help me to understand this and to modify as per my need. i think its in VB, where as mine is VBA.
Code:
Dim cn As ADODB.Connection
    Dim strSQL As String
    Dim lngRecsAff As Long
    Set cn = New ADODB.Connection
    cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=C:\test\xltestt.xls;" & _
        "Extended Properties=Excel 8.0"
    
    'Import by using Jet Provider.
    strSQL = "SELECT * INTO [odbc;Driver={SQL Server};" & _
        "Server=<server>;Database=<database>;" & _
        "UID=<user>;PWD=<password>].XLImport9 " & _
        "FROM [Customers$]"
    Debug.Print strSQL
    cn.Execute strSQL, lngRecsAff, adExecuteNoRecords
    Debug.Print "Records affected: " & lngRecsAff
        
    cn.Close
    Set cn = Nothing
 
Maybe you want to use the upsizing wizard to put your access table in SQL server?

Do you NEED to do this programmatically? If so, why?
Why are you trying to do this in Access instead of VB.NET or using SQL Server tools to do it?

I don't have a good answer for you, I am hoping to be able to steer you in the right direction.
 
i used this code, and i am getting the error saying" The expression you entered is wrong datatype for one of the arguments."
i know i selected access database.

any idea. btw i am trying to import the selected table into sql server, which is my backend.
ANY HELP

Private Sub Listtables_AfterUpdate()
docmd.TransferDatabase acImport, "Microsoft Access", dbname, acTable, Me.ListTables, Me.ListTables
end Sub
 
help me out here guys. it still gives me the expression you entered is wrong data type'
i even tried this with DSN

Private Sub ListTables_AfterUpdate()
docmd.TransferDatabase acLink, "Microsoft Access", dbname, acTable, Me.ListTables, Me.ListTables
docmd.TransferDatabase acExport, "ODBC Database", "ODBC;DSN=dsnname;LANGUAGE=us_english;DATABASE=databasename", acTable, Me.ListTables, Me.ListTables
End Sub

still gives me same error.let me know where i went wrong...

 
guys please help me out here.
wha ti am trying to do is import access table in my current back end database which is sql server, and my front end is access( using 2000).

after browsing accessdatabase and listing tables in listbpx, i wanted to import to my currentdatabase by selecting tabels from listbox.and i tried same code as well.without linking odbc databse and with linking none are working.
Private Sub Listtables_AfterUpdate()
docmd.TransferDatabase acImport, "Microsoft Access", dbname, acTable, Me.ListTables, Me.ListTables
end Sub



i donot know why its doing this...

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top