小编Mar*_*cus的帖子

连接必须有效且打开错误

我收到提示:连接必须是有效和打开,当我启动该程序.我搜索谷歌和只发现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)

c# mysql

7
推荐指数
1
解决办法
4万
查看次数

如何在C#中获取列表中新添加项的索引?

当我将一个项目(一个类的实例)添加到列表中时,我需要知道新项目的索引.任何功能都可以吗?

示例代码:

MapTiles.Add(new Class1(num, x * 32 + cameraX, y * 32 + cameraY));
Run Code Online (Sandbox Code Playgroud)

c# indexing list

4
推荐指数
2
解决办法
3084
查看次数

将文字添加到char*

是否可以添加文本char*

因为此代码会出错:

name3 = "SELECT account_id FROM players WHERE name = '" + name + "'";
Run Code Online (Sandbox Code Playgroud)

(name3 = char*)

c++ sql pointers string-concatenation

1
推荐指数
1
解决办法
6277
查看次数

如何在所有其他控件下方显示面板控件?

我在WinForms应用程序中遇到面板控件问题.如何让它在其他一切之下呢?现在,文本在面板下.

.net c# panel winforms

1
推荐指数
1
解决办法
5115
查看次数

C#按X和Y对列表进行排序

我需要按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# sorting list

1
推荐指数
1
解决办法
1228
查看次数

如何用C#读取列和行?

您好我需要一个代码来读取C#的列和行.

我走到这一步:

obj.MysqlQUERY("SELECT * FROM `players` WHERE name = "+name+";"); // my query function
Run Code Online (Sandbox Code Playgroud)

感谢帮助;]

c# mysql rows

0
推荐指数
1
解决办法
2万
查看次数

在C#中启动程序,包括所有文件

我在运行程序时遇到问题.

当我开始这个过程时,它说"找不到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)

感谢帮助!!

c# process

0
推荐指数
1
解决办法
168
查看次数

使用 MySqlDataReader 读取

您好,我在阅读时遇到问题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)

c# mysql connector

0
推荐指数
1
解决办法
3万
查看次数

标签 统计

c# ×7

mysql ×3

list ×2

.net ×1

c++ ×1

connector ×1

indexing ×1

panel ×1

pointers ×1

process ×1

rows ×1

sorting ×1

sql ×1

string-concatenation ×1

winforms ×1