473,386 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Connecting Access to SQL Server

I am totally new to ADO and I am wanting to connect an Access database to SQL Server database to bring back data tables. The SQL Server is on a Remote Desktop, and I dont want to just link the tables as that would mean I am permenantly connected to the SQL Server, I cant have this as sometimes I will need the Access database when I dont have a connection to the Remote Desktop.
I have read through some of the threads already about connecting and am totally lost, can someone write me a connection code that would bring a table from SQL Server and import it into a table in my access databse, can you also anotate it so that I can follow it through and try and understand what its doing.

I would be very grateful if this could be done.

Thanks,
Jez
Jul 1 '07 #1
4 1874
NeoPa
32,556 Expert Mod 16PB
Everyone's a comedian today.
This site is not a free programming resource for those unprepared to do their own code.
We can lead and help YOU to do YOUR work.

MODERATOR.
Jul 2 '07 #2
NeoPa
32,556 Expert Mod 16PB
Having said that, I think an ODBC connection would probably suit you well enough as there is no penalty for having a connected or linked table which you only use when the connection is there.
Jul 2 '07 #3
Having said that, I think an ODBC connection would probably suit you well enough as there is no penalty for having a connected or linked table which you only use when the connection is there.
If I dont have access to the Remote Connection, the linking of tables is no use, as it wont run any query that I have in my database. Thats why I have been looking at ADO as a connection to the SQL Server and once imported the tables then ending the connection, this gives me full access to the data in the tables.
Jul 3 '07 #4
Everyone's a comedian today.
This site is not a free programming resource for those unprepared to do their own code.
We can lead and help YOU to do YOUR work.

MODERATOR.
I was wanting help rather than someone totally write it, as then I can understand what its doing.

This below is my code that have written, but I keep getting an error message on the line highlighted with stars.

The error is - 3704 - Operation is not allowed when the object is closed. what does this mean?

Private Sub cmdImport_Click()
Dim Conn As ADODB.Connection
Dim RS As ADODB.Recordset
Dim Comm As ADODB.Command

Dim objConn As New ADODB.Connection
Dim objRS As New ADODB.Recordset

Dim strConn As String
Dim strInsert As String
Dim strSelect As String

strConn = "Provider=sqloledb;Data Source=SLIDER\BISR;Initial" & _
"Catalog=NameofSQLServer;User Id=myunsername;Password=mypassword"

strSelect = "SELECT * FROM dbo.servicing_jobs"

********Set objRS = objConn.Execute(strSelect)*******

Set Conn = New ADODB.Connection
Set RS = New ADODB.Recordset
Set Comm = New ADODB.Command

Conn.Open strConn
Comm.ActiveConnection = Conn
Comm.CommandType = adCmdText

Do While Not objRS.EOF
strInsert = "INSERT INTO tblServicing"

Comm.CommandText = strInsert
Comm.Execute

objRS.MoveNext
Loop

UpdateAwardErr:
If Err.Number <> 0 Then
MsgBox Err.Number & Err.Description
Exit Sub
Else
MsgBox "Records were successfully inserted", vbInformation, "ServicingJobs Update"
Exit Sub
End If
End Sub
Jul 3 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Dan | last post by:
Hi, I'm planning to develop a small intranet to provide our organization with documents online. I've decided to do this using jsp/servlets using a tomcat server. For an operating system, I...
3
by: kamilla | last post by:
I have a mysql 3.5 server installed on a suse linux 8.1, with address 10.0.0.100. Now I want to access that db from a W2K pc, address 10.0.0.200. I am able to ping 10.0.0.100, but I cannot connect...
4
by: John Morgan | last post by:
I have Enterprise Manager on my local machine. For the last twelve months it has been connecting without problem to my online SQL Server database provided by my ISP. Three weeks ago the ISP...
2
by: news | last post by:
We currently have our mySQL server on the same box as the Apache server. For security and load balancing, we're going to be moving the mySQL server to another box. We're already using a single...
1
by: Dishaa V | last post by:
Hello I need to connect to an access db which is on the internet. I do know that URL of the same. its http://www.vallury.com/balance/bank.mdb. Its just a test db. How can I connect to that db...
12
by: Ann Marinas | last post by:
Hi all, I would like to ask for some help regarding separating the asp.net webserver and the sql server. I have created an asp.net application for a certain company. Initially, we installed...
5
by: bill | last post by:
I am having difficulties connecting to a remote Sql server database in VB.net. Lets say my remote server is found at 255.255.255.255 and its name is MyServer. The database is called MyDatabase....
3
by: Chris | last post by:
Don't know if there is a simple solution for this one or not. When running SQL server on a machine with 2000 loaded and the complete SQL package I don't have any issues. Now I'm trying to login...
2
by: Patrick F | last post by:
Hi, i have SQL Server 2005 and a database set that is called, myCompany the problem is that i cant connect from my page to it, here is from the web.config: ( i have got this connectionstring from...
2
by: orandov | last post by:
Hi, I am having a problem connecting my .net applications from the application server to the database server. When I run the application from my windows xp (sp2) box it works fine. When I try to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.