分享

asp.net如何连接MySQL

 woodsia 2008-08-10
asp.net如何连接MySQL
录入时间:2008-07-17 15:14 类别:电脑常识 共享:否    

问:
请问asp.net如何连接MySQL?
另外asp.net如何连接远程的MySQL?
谢谢
______________________________________________________________________________________________
答1:
http://www./products/myodbc/manual.html#ODBC.NET(C#)


http://www.csdn.net/Develop/read_article.asp?id=16437

.NET中各种数据库连接大全


______________________________________________________________________________________________
答2:
oConn.Open "Provider=MySQLProv;" & _
           "Data Source=mySQLDB;" & _
           "User Id=myUsername;" & _
           "Password=myPassword"

______________________________________________________________________________________________
答3:
下载一个mysql的ODBC就行了,这个ODBC在mysql网站上有。
______________________________________________________________________________________________
答4:
<%@ Page Language="vb" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<html>
<script language="VB" runat="server">
 Sub Page_Load(Src As Object, E As EventArgs)
    Dim myConnection As SqlConnection
      myConnection = New SqlConnection("server=localhost;" _
         & "database=数据库;USER ID=sa;PWD=")
      Dim myCommand As SqlDataAdapter = New SqlDataAdapter("SELECT *" _
         & " FROM 表", myConnection)
     Dim ds As DataSet = New DataSet()
      myCommand.Fill(ds)
      Dim view As DataView = ds.Tables(0).DefaultView
      view.Sort = sortField & " ASC"
      MyDataGrid.DataSource = view
      MyDataGrid.DataBind()
   End Sub
</script>

<body>
   <%-- Display the data  in the body of the page. --%>
   <h3><font face="Verdana">Sorting Data in a DataGrid Control</font></h3>
   <%-- Within a form, create a DataGrid control and initialize its
      attributes. --%>
   <form runat="server">
      <ASP:DataGrid id="MyDataGrid" runat="server"
         OnSortCommand="MyDataGrid_Sort"
         Width="700"
         BackColor="#ccccff"
         BorderColor="black"
         ShowFooter="false"
         CellPadding=3
         CellSpacing="0"
         Font-Name="Verdana"
         Font-Size="8pt"
         HeaderStyle-BackColor="#aaaadd"
         AllowSorting="true"
      />
   </form>
</body>
</html>

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多