qq_kong
qq_kong
2017-03-02 12:56

C#中添加MySql的问题,请问大佬应该怎么修改,或者给出在C#中使用mysql的语句也行~感谢

10
  • c#
  • mysql

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using MySQLDriverCS;

public DataTable GetDataTable()
{
MySQLConnection conn = new MySQLConnection(new MySQLConnectionString("localhost","t2","Uxie","Sad-Mothday5^&").AsString);
conn.Open();
MySQLCommand commn = new MySQLCommand("set names gb2312", conn);
commn.ExecuteNonQuery();
string sql = "select * from tb1";
MySQLDataAdapter mda = new MySQLDataAdapter(sql,conn);
DataTable dt = new DataTable();
mda.Fill(dt);
conn.Close();
return dt;
}

那个DataTable后面的GetDataTable()一直是红线提醒
命名空间不能直接包含字段或方法之类的成员
请问应该怎么修改???

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答