简体   繁体   English

MS访问SQL Server连接

[英]MS Access to SQL Server connection

I'm using MS Access as my database, my hosting is not supporting this, and I need to know how to convert MS Access to SQL Server connection string? 我使用MS Access作为数据库,我的主机不支持此功能,我需要知道如何将MS Access转换为SQL Server连接字符串?

This my code of data connection: 这是我的数据连接代码:

'--------------- ole parameters -------------------
Dim olecommand As Data.OleDb.OleDbCommand
Dim oledataadaptor As Data.OleDb.OleDbDataAdapter
Dim odbcDataSet As System.Data.DataSet

Sub populate_dataset_Access_accdb_test(ByRef ds As DataSet, ByVal sql As String)
    Dim myDataConnection As New OleDbConnection(ConfigurationManager.ConnectionStrings("myodbc").ConnectionString)
    olecommand = New OleDb.OleDbCommand
    olecommand.CommandText = sql
    odbcDataSet = New System.Data.DataSet
    olecommand.Connection = myDataConnection

    myDataConnection.Open()
    oledataadaptor = New OleDbDataAdapter(sql, myDataConnection)
    oledataadaptor.Fill(ds)

    myDataConnection.Close()

End Sub

Sub insert_dataset_Access_accdb_test(ByVal sql As String)
    Dim myDataConnection As New OleDbConnection(ConfigurationManager.ConnectionStrings("myodbc").ConnectionString)
    olecommand = New OleDb.OleDbCommand
    olecommand.CommandText = sql
    odbcDataSet = New System.Data.DataSet
    olecommand.Connection = myDataConnection

    myDataConnection.Open()
    olecommand = New OleDbCommand(sql, myDataConnection)
    olecommand.ExecuteNonQuery()


    myDataConnection.Close()

End Sub

Sub cr_ds(ByRef ds As DataSet, ByVal sql As String, ByVal tablename As String)
    Dim myDataConnection As New OleDbConnection(ConfigurationManager.ConnectionStrings("myodbc").ConnectionString)
    olecommand = New OleDb.OleDbCommand
    olecommand.CommandText = sql
    odbcDataSet = New System.Data.DataSet
    olecommand.Connection = myDataConnection

    myDataConnection.Open()
    oledataadaptor = New OleDbDataAdapter(sql, myDataConnection)
    oledataadaptor.Fill(ds, tablename)

    myDataConnection.Close()
End Sub

Thank you in advance 先感谢您

You can't just change an Access connection string to an SQL connection string and have things work. 您不能只是将Access连接字符串更改为SQL连接字符串并使事情起作用。 You would have to port your data From Access to the SQL Server. 您必须将数据从Access移植到SQL Server。

I think it is more likely that when you deploy your Access database to the server, the path is different. 我认为将Access数据库部署到服务器时,路径的可能性更大。 You probably need to modify the config file to point to to where the Access file is on the server. 您可能需要修改配置文件,以指向Access文件在服务器上的位置。

As Steve Wellens pointed out, you miss some basic things here. 正如史蒂夫·韦伦斯(Steve Wellens)所指出的,您在这里错过了一些基本的知识。 Since your host does not support your data source type (MS Access), changing your connection string is not enough . 由于主机不支持数据源类型(MS Access),因此仅更改连接字符串是不够的 You have to use a data store supported by your hosting service. 您必须使用托管服务支持的数据存储。 I suppose that Microsoft SQL Server is one of them, but you have to verify it by contacting your hosting service administration support. 我想Microsoft SQL Server就是其中之一,但是您必须通过联系托管服务管理支持来进行验证。

Regarding the transfer of data between MS Access and MS SQL Server, you could get some guidance here . 关于MS Access和MS SQL Server之间的数据传输,您可以在此处获得一些指导。

Regarding the MS SQL Server connection strings, you could get some help from this post but you have to verify the availability of the MS SQL Server database with your hosting service. 关于MS SQL Server连接字符串,您可以从本文中获得一些帮助,但您必须通过托管服务来验证MS SQL Server数据库的可用性。

Hope I helped! 希望我能帮上忙!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM