分享

写回答

发帖

[提问] ===晕死哦,GODADDY上ASP.NET + MYSQL到底要怎样连接?===

GoDaddy GoDaddy 1420 人阅读 | 4 人回复

发表于 2011-1-13 10:43:30 | 显示全部楼层 |阅读模式

折腾了一整天,试了三种方法:
1.用MySQL Net 6.3.5连接提示如下:
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
2.用ODBC方式连接提示
Access denied for user: '***@******' (Using password: YES),向上帝保证我的用户名和密码也是正确的,在本地报这个错还好解决,远程主机上如何解决?
3.用OLEDB方式提示:
The 'MySQL Provider' provider is not registered on the local machine.
在本地可以连接成功,上传到空间就报这个错.
有谁能帮帮我啊

回答|共 4 个

add.c

发表于 2011-1-13 10:53:43 | 显示全部楼层

ASP/ADO连接示例代码
  1. <%
  2. Dim oConn, oRs
  3. Dim qry, connectstr
  4. Dim db_name, db_username, db_userpassword
  5. Dim db_server

  6. db_server = "mysql.secureserver.net"
  7. db_name = "your_dbusername"
  8. db_username = "your_dbusername"
  9. db_userpassword = "your_dbpassword"
  10. fieldname = "your_field"
  11. tablename = "your_table"

  12. connectstr = "Driver={MySQL ODBC 3.51 Driver};SERVER=" & db_server & ";DATABASE=" & db_name & ";UID=" & db_username & ";PWD=" & db_userpassword

  13. Set oConn = Server.CreateObject("ADODB.Connection")
  14. oConn.Open connectstr

  15. qry = "SELECT * FROM " & tablename

  16. Set oRS = oConn.Execute(qry)

  17. if not oRS.EOF then
  18. while not oRS.EOF
  19. response.write ucase(fieldname) & ": " & oRs.Fields(fieldname) & "
  20. "
  21. oRS.movenext
  22. wend
  23. oRS.close
  24. end if

  25. Set oRs = nothing
  26. Set oConn = nothing

  27. %>
复制代码

benzhu

发表于 2011-1-13 11:08:03 | 显示全部楼层

上面是ASP的代码,不是ASP.NET,我代码肯定是没错的,在本地都能运行正常

getst

发表于 2011-1-13 11:28:30 | 显示全部楼层

lz装什么系统,搞出net+mysql的组合?

benzhu

发表于 2011-1-13 11:52:23 | 显示全部楼层

win主机哈,以前用的SQLSERVER2005的库,但SQLSERVER库限制200M
您需要登录后才可以回帖 登录 | 注册

本版积分规则