简体   繁体   English

如何使用 ASP.Net 数据源通过 ODBC DSN 连接到 Access 数据库?

[英]How do I connect to an Access Database through an ODBC DSN using an ASP.Net Data Source?

I have a dsn connection to the database and I have the following command in asp.net to connect to it我有一个到数据库的 dsn 连接,我在 asp.net 中有以下命令来连接它

<asp:AccessDataSource ID="SqlDataSource1" runat="server" DSN="tuition" SelectCommand="Select * From [table1]"></asp:AccessDataSource> 

However the problem is that when using AccessDataSouce we can't use DSN.然而问题是当使用 AccessDataSouce 时我们不能使用 DSN。 Is their any other way to get around that( or probably use something else ).他们是否有任何其他方式来解决这个问题(或者可能使用其他东西)。 As long as Im using DSN Im fine, any help would be greatly appreciated.只要我使用 DSN 我很好,任何帮助都将不胜感激。 Thanks,谢谢,

Note I have an MS Access Database and Im connecting through odbc注意我有一个 MS Access 数据库,我通过 odbc 连接

Check out this article...看看这篇文章...

http://msdn.microsoft.com/en-us/library/35c54x95(v=vs.80).aspx http://msdn.microsoft.com/en-us/library/35c54x95(v=vs.80).aspx

it explains how to connect to an ODBC database using a SqlDataSource instead of an AccessDataSource .它解释了如何使用SqlDataSource而不是AccessDataSource连接到 ODBC 数据库。 This method should allow you use your DSN if you specify it in the "server" property:如果您在“服务器”属性中指定,此方法应该允许您使用您的 DSN:

<configuration>
  <connectionStrings>
    <add 
      name="ODBCDataConnectionString" 
      connectionString="Driver=ODBCDriver;server=tuition;"
      providerName="System.Data.Odbc"
    />
  </connectionStrings>
</configuration>

Then change your data source to:然后将您的数据源更改为:

<asp:SqlDataSource 
  ID="SqlDataSource1" 
  Runat="server" 
  SelectCommand="Select * From [table1]"
  ConnectionString="<%$ ConnectionStrings:ODBCDataConnectionString %>"
  ProviderName="<%$ ConnectionStrings:ODBCDataConnectionString.ProviderName %>" />

暂无
暂无

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

相关问题 如何通过IIS 7.5使用集成管道模式和ASP.Net应用程序连接到Oracle数据库? - How do I connect to an Oracle database using integrated pipeline mode with an ASP.Net application through IIS 7.5? 如何连接到SQL Server并通过ASP.NET Web窗体查看数据库中的数据? - How can I connect to SQL Server and view the data in the database through ASP.NET Web Form? ASP.NET应用程序无法找到或连接到64位Oracle Driver的DSN,错误为找不到数据源名称 - ASP.NET application is not able to find or connect to DSN of 64 bit Oracle Driver with error Data source name not found 如何使用ASP.NET在Access数据库中插入关系数据 - How to insert relational data in Access database using ASP.NET 如何使用 ASP.NET 将数据保存到 MySql 数据库中 - How do I save data into MySql database using ASP.NET 使用ODBC通过ASP.NET连接到MySql - Connecting to MySql through ASP.NET using ODBC Asp.Net中的ODBC连接(连接和处置) - ODBC Connection in Asp.Net (Connect and Dispose) 如何将 Razor Pages ASP.NET 应用程序连接到现有的非本地 MSSQL 数据库? - How do I connect a Razor Pages ASP.NET app to an already existing, not local MSSQL database? 如何使用带有ASP.Net/C#的MySQL ODBC将自动增量ID插入MySQL表? - How do I insert the auto-increment ID into a MySQL table using MySQL ODBC with ASP.Net/C#? 如何使用mysql在asp.net中连接远程数据库? - How to connect remote database in asp.net using mysql?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM