首页 > 学院 > 开发设计 > 正文

C#.NET连接mysql方法

2019-11-17 04:07:59
字体:
来源:转载
供稿:网友
view plaincopy to clipboardPRint?
·········10········20········30········40········50········60········70········80········90········100·······110·······120·······130·······140·······150
using MySQL.Data.MySqlClient;   
public partial class _Default : System.Web.UI.Page    
{   
    protected void Page_Load(object sender, EventArgs e)   
    {   
        string myConnectionString = "Database=test;Data Source=localhost;User Id=root;PassWord=admin";   
        MySqlConnection mycn = new MySqlConnection(myConnectionString);   
           
        try  
        {   
            mycn.Open();   
            Response.Write("<mce:script type="text/javascript"><!--   
alert('连接成功')   
// --></mce:script>");   
        }   
        catch (Exception ex)   
        {   
            Response.Write("<mce:script type="text/Javascript"><!--   
alert(" ex.ToString() ")   
// --></mce:script>");   
        }   
    }   
}  
上一篇:C# Excel 交互类

下一篇:C# 调整系统时间

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表