Connection to remote server
I have 2 websites. On the first i have a table with news articles in an access database.
Now, my question:
On the second site i'd like to open the access-db on the first site and display these news. Both are on public servers, so i dont have the path for tha actual file. I use 'server.mappath("database.mdb")' in my connectionstring locally.
but how to connect to 'http://www.mysite.com/database.mdb'?
Cheers,
Per
2 answers
Hi
There is something called RDS (or MS Remote).
However these components are considered deprecated...
http://msdn.microsoft.com/en-us/library/ms811968
Microsoft advises using the SOAP Toolkit but Im not sure if that's the way to go here.
If the websites are located on the same servers I would see if it would be possible to set up a shared "Data" folder by the hosting company so that you could access it by file path. Access over HTTP is not prefered if you can find a solution going through a file share.
Hope this helps...
Option Strict On
Option Explicit On
Imports System.Data
Imports System.Data.OleDb
Partial Class _Default
Inherits System.Web.UI.Page
Dim conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source= " & Server.mappath("Tabellenname.accdb"))
Dim adapEINS As New OleDbDataAdapter("Select * from XY", conn)
Dim ds As New DataSet
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
'Daten ins Griedview
adapEINS.Fill(ds, "XY")
GridView1.DataSource = ds.Tables("XY")
GridView1.DataBind()
'Drop Down befüllung"
If Not IsPostBack Then
'befüllung der DDL Listen
DDL_eins.DataSource = ds.Tables("XY")
DDL_eins.DataTextField = "Spaltenname"
DDL_eins.DataValueField = "Spaltenname2"
DDL_eins.DataBind()
End If
'commands anlegen
'Insert
Dim cmdins As New OleDbCommand("Insert into tabelleXY(Spalte1,Spalte2) Values (?,?);", conn)
cmdins.Parameters.Add("@Spalte1", OleDbType.Integer, 0, "Spalte1")
cmdins.Parameters.Add("@Spalte2", OleDbType.Single, 0, "Spalte2")
adapEINS.InsertCommand = cmdins
'Update
Dim cmdUpd As New OleDbCommand("Update Tabelle1 set Spalte1 = ? where spalte2 = ? and spalte3 = ?;", conn)
'delete reicht primärschlüssel
'Prmärschlüssel anlegen
ds.Tables("XY").PrimaryKey = {ds.Tables("XY).columns("spalte1"), ds.Tables("XY").Columns("spalte3")}
Dim zeile As DataRow = ds.Tables("XY").Rows.find{DDL_eins.selectetvalue, DDL_zwei.selectetvalue}
'neue zeile anlegen tabelle
Dim zeile As DataRow = ds.Tables("XY").NewRow
zeile("Spalte1") = DDL_eins.SelectedValue
zeile("Spalte2" = DDL_zwei.selectetValue
ds.Tables("XY".rows.add(zeile)