本文整理汇总了C#中MySql.Data.MySqlClient.MySqlDataReader.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# MySqlDataReader.Dispose方法的具体用法?C# MySqlDataReader.Dispose怎么用?C# MySqlDataReader.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MySql.Data.MySqlClient.MySqlDataReader
的用法示例。
在下文中一共展示了MySqlDataReader.Dispose方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: executarConsulta
public MySqlDataReader executarConsulta(MySqlCommand cmm)
{
conectar();
cmm.Connection = conn;
try
{
dr = cmm.ExecuteReader();
}
catch (MySqlException ex)
{
dr.Dispose();
throw ex;
}
return dr;
}
示例2: JsonSend
public void JsonSend(string[] jSon)
{
if (DataToConnect == null || !_isEnabled) return;
try
{
if (jSon.Length != 4) throw new Exception("This is not property jSon data.");
//Prepare a new _connection
_connection = new MySqlConnection(DataToConnect);
//open mysql client
_connection.Open();
string latin1Command1 = UTF8toLatin
($"insert into dane(IDUrzadzenia, dane, czas, data) values('{jSon[0]}','{jSon[1]}','{jSon[2]}','{jSon[3]}');");
_categoriesCommand = new MySqlCommand(latin1Command1, _connection);
_reader = _categoriesCommand.ExecuteReader();
while (_reader.Read())
{
}
_reader.Dispose();
SendMessage("Log sent to Remote database.");
}
catch
{
SendMessage("Can't connect to remote database! Check all.");
}
}
示例3: ReadTotal
public static string ReadTotal(string query,string row,string morequery = null)
{
try{
if (con.State.ToString() != "Open")
con.Open();
using(con){
using(cmd = new MySqlCommand(query, con)){
rdr = cmd.ExecuteReader();
if(rdr.HasRows)
while (rdr.Read())
Debug.Log(rdr[row].ToString());
rdr.Dispose();
}
}
}
catch (Exception ex){
return ex.ToString();
}
return "";
}
示例4: ReadEntries
// Read all entries from the table
void ReadEntries()
{
string query = string.Empty;
if (_GameItems == null)
_GameItems = new List<data>();
if (_GameItems.Count > 0)
_GameItems.Clear();
// Error trapping in the simplest form
try
{
query = "SELECT * FROM view_demo";
if (con.State.ToString() != "Open")
con.Open();
using (con)
{
using (cmd = new MySqlCommand(query, con))
{
rdr = cmd.ExecuteReader();
if (rdr.HasRows)
while (rdr.Read())
{
data itm = new data();
itm.UID = int.Parse(rdr["iddemo_table"].ToString());
itm.ID = rdr["ID"].ToString();
itm.levelname = rdr["levelname"].ToString();
itm.Name = rdr["Name"].ToString();
itm.objectType = rdr["objectType"].ToString();
itm.posx = float.Parse(rdr["posx"].ToString());
itm.posy = float.Parse(rdr["posy"].ToString());
itm.posz = float.Parse(rdr["posz"].ToString());
itm.tranx = float.Parse(rdr["tranx"].ToString());
itm.trany = float.Parse(rdr["trany"].ToString());
itm.tranz = float.Parse(rdr["tranz"].ToString());
_GameItems.Add(itm);
}
rdr.Dispose();
}
}
}
catch (Exception ex)
{
Debug.Log(ex.ToString());
}
finally
{
}
}
示例5: LogIn
void LogIn(NetworkMessage netMsg, InfoMessage msg)
{
bool loggedIn = false;
string query = "SELECT * FROM shogi.players WHERE players_email = \"" + msg.email + "\"";
if (con.State.ToString () != "Open")
con.Open ();
using (con) {
using (cmd = new MySqlCommand (query, con)) {
rdr = cmd.ExecuteReader();
if (rdr.HasRows) {
rdr.Read ();
if (msg.password == rdr["players_password"].ToString ()) {
incomeMessages.text += netMsg.conn.address + " logged in as " + msg.email + "\n";
loggedIn = true;
}
else
incomeMessages.text += netMsg.conn.address + " failed logging in for wrong password " + msg.password + "\n";
}
else
incomeMessages.text += netMsg.conn.address + " failed logging in for no entry " + msg.email + "\n";
rdr.Dispose ();
}
string queryIP = "UPDATE shogi.players SET players_ip = \"" + netMsg.conn.address + "\" WHERE players_email = \"" + msg.email + "\"";
if (loggedIn) {
using (cmd = new MySqlCommand (queryIP, con))
cmd.ExecuteNonQuery ();
msg.goal = "loggedin";
NetworkServer.SendToClient(netMsg.conn.connectionId, MyMsgType.Info, msg);
}
}
}
示例6: executarConsulta
public MySqlDataReader executarConsulta(string pSql)
{
conectarDB();
cmm = new MySqlCommand(pSql, conn);
try
{
dr = cmm.ExecuteReader();
}
catch (MySqlException ex)
{
dr.Dispose();
throw ex;
}
return dr;
}
示例7: LoadGameState
/// <summary>
/// Load gamestate from current player
/// </summary>
/// <param name="result"></param>
public void LoadGameState(MySqlDataReader result)
{
result.Read();
player.Gold = result.GetInt32(1);
this.turn = result.GetInt32(2);
List<Cargo> clist = player.GetPlayersCargoList();
int i = 3;
foreach (Cargo cargo in player.GetPlayersCargoList())
{
cargo.Amount = result.GetInt32(i);
i++;
}
foreach (Port port in portList)
{
i=12;
foreach (Cargo cargo in port.GetPortsCargoList())
{
cargo.Price = result.GetInt32(i);
i++;
}
}
result.Dispose();
}