我收到提示:连接必须是有效和打开,当我启动该程序.我搜索谷歌和只发现2人有相同的错误.有可能解决这个问题吗?谢谢
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Data.Odbc;
using System.Data.Sql;
namespace WindowsFormsApplication1
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
string connectionString = "Server=localhost;Uid=root;Pwd=******;Database=testing;";
MySql.Data.MySqlClient.MySqlConnection connection = new MySql.Data.MySqlClient.MySqlConnection(connectionString);
connection.Open();
string insertQuery = "ALTER TABLE `user` ADD lol INT";
MySql.Data.MySqlClient.MySqlCommand myCommand = new MySql.Data.MySqlClient.MySqlCommand(insertQuery);
myCommand.ExecuteNonQuery();
connection.Close();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
Run Code Online (Sandbox Code Playgroud) 当我将一个项目(一个类的实例)添加到列表中时,我需要知道新项目的索引.任何功能都可以吗?
示例代码:
MapTiles.Add(new Class1(num, x * 32 + cameraX, y * 32 + cameraY));
Run Code Online (Sandbox Code Playgroud) 是否可以添加文本char*?
因为此代码会出错:
name3 = "SELECT account_id FROM players WHERE name = '" + name + "'";
Run Code Online (Sandbox Code Playgroud)
(name3 = char*)
我在WinForms应用程序中遇到面板控件问题.如何让它在其他一切之下呢?现在,文本在面板下.
我需要按X和Y排序列表.我读了一些其他问题来排序X和Y,但我不明白:
List<SomeClass>() a;
List<SomeClass> b = a.OrderBy(x => x.x).ThenBy(x => x.y).ToList();
Run Code Online (Sandbox Code Playgroud)
我的意思是,x => xx给出未声明的变量错误.
问题是:如何按列表中的X和Y排序,或者:要使用什么变量而不是x => xx ????
编辑:对,我的列表是这样的:
List<Class1> MapTiles;
Run Code Online (Sandbox Code Playgroud)
在类中:int ID,int X,int Y.
感谢名单.
您好我需要一个代码来读取C#的列和行.
我走到这一步:
obj.MysqlQUERY("SELECT * FROM `players` WHERE name = "+name+";"); // my query function
Run Code Online (Sandbox Code Playgroud)
感谢帮助;]
我在运行程序时遇到问题.
当我开始这个过程时,它说"找不到Tibia.dat!" (它认为exe文件位于项目目录中,当它不是时).
因此,当我在我的程序中启动该过程时(来自:C:\ program\Tibia\Tibia.exe),它说"找不到C:\ user\marcus\my documents\visual studio 2009\blablalba\Tibia.dat".
这是我正在使用的代码:
Process.Start(addressToFirstTibia + "\\Tibia.exe");
Run Code Online (Sandbox Code Playgroud)
感谢帮助!!
您好,我在阅读时遇到问题MySqlDataReader。我尝试更改while()为if(),然后它起作用了。所以我做错了while (Reader.Read())。谢谢你的回答。(今天的另一个问题已解决,评论的人帮助了我xd)
using (MySqlCommand cmd = new MySqlCommand
("SELECT * FROM `citationer`", mysqlCon))
{
try
{
MySqlDataReader Reader = cmd.ExecuteReader();
while (Reader.Read()) // this part is wrong somehow
{
citationstexter.Add(Reader.GetString(loopReading)); // this works
loopReading++; // this works
}
Reader.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Run Code Online (Sandbox Code Playgroud)