Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 更新mysql数据库(DDT groupname) 为什么列名周围有单引号。。?还有什么问题和/或问题。。如果您得到任何SqlExceptions,那么请发布错误,并使用(){}将Sql对象包装在周围,这样您就不必显式调用Close并进行处理。问题是系统不_C#_Mysql_Visual Studio_Sql Update - Fatal编程技术网

C# 更新mysql数据库(DDT groupname) 为什么列名周围有单引号。。?还有什么问题和/或问题。。如果您得到任何SqlExceptions,那么请发布错误,并使用(){}将Sql对象包装在周围,这样您就不必显式调用Close并进行处理。问题是系统不

C# 更新mysql数据库(DDT groupname) 为什么列名周围有单引号。。?还有什么问题和/或问题。。如果您得到任何SqlExceptions,那么请发布错误,并使用(){}将Sql对象包装在周围,这样您就不必显式调用Close并进行处理。问题是系统不,c#,mysql,visual-studio,sql-update,C#,Mysql,Visual Studio,Sql Update,更新mysql数据库(DDT groupname) 为什么列名周围有单引号。。?还有什么问题和/或问题。。如果您得到任何SqlExceptions,那么请发布错误,并使用(){}将Sql对象包装在周围,这样您就不必显式调用Close并进行处理。问题是系统不会崩溃,数据也不会更新,我将删除单个qoutes并运行。在pageload中,我有一个填充文本框的select语句,我必须为它包含一个单引号,以便将sql字符串更改为以下string command=“Update fixture SET re

更新mysql数据库(DDT groupname)
为什么列名周围有单引号。。?还有什么问题和/或问题。。如果您得到任何
SqlExceptions
,那么请发布错误,并使用(){}将Sql对象包装在
周围,这样您就不必显式调用Close并进行处理。问题是系统不会崩溃,数据也不会更新,我将删除单个qoutes并运行。在pageload中,我有一个填充文本框的select语句,我必须为它包含一个单引号,以便将sql字符串更改为以下
string command=“Update fixture SET reference=@reference,”+“ScoreA=@ScoreA,ScoreB=@ScoreB,Winner=@Winner”+“WHERE idfixture=“+Request.QueryString[“idfixture”];
还将代码包装在
try{}catch{SqlException sqlEx}
另外,如果您不确定如何使用
MySql
配置连接字符串,请查看此处的链接这是代码,是否接受id,是否已连接您正在使用的
数据库
是什么..?请确保您有权为Sql用户授予
插入、更新
的权限…也不要发布此代码如果它不起作用,则作为答案。这应该放在您通过编辑原始问题发布的原始问题中
MySqlConnection conn = new MySqlConnection("server=localhost;uid=root;" + "pwd=password;database=ddt_data");

conn.Open();
string command = "Update `fixture` SET `referee`=@referee, `ScoreA`=@ScoreA, `ScoreB`=@ScoreB, `Winner`=@Winner WHERE idfixture=" + Request.QueryString["idfixture"];
MySqlCommand update = new MySqlCommand(command, conn);

update.Parameters.AddWithValue("@referee", this.txtRef.Text);
update.Parameters.AddWithValue("@scorea", this.txtScoreA.Text);
update.Parameters.AddWithValue("@scoreb", this.txtScoreB.Text);
update.Parameters.AddWithValue("@winner", this.txtWinner.Text);

update.ExecuteNonQuery(); // use this if you don't need the DataReader
conn.Close();
conn.Dispose();        
        MySqlConnection conn = new MySqlConnection("server=localhost;uid=root;" + "pwd=password;database=ddt_data");
        conn.Open();
        try
        {

            string command = "Update fixture SET referee =@referee," + "ScoreA = @ScoreA, ScoreB = @ScoreB, Winner = @Winner " + "WHERE idfixture= " + Request.QueryString["idfixture"];
            MySqlCommand update = new MySqlCommand(command, conn);
            update.Parameters.AddWithValue("@referee", this.txtRef.Text);
            update.Parameters.AddWithValue("@scorea", this.txtScoreA.Text);
            update.Parameters.AddWithValue("@scoreb", this.txtScoreB.Text);
            update.Parameters.AddWithValue("@winner", this.txtWinner.Text);
            update.ExecuteNonQuery(); // use this if you don't need the DataReader
            conn.Close();
            conn.Dispose();
        }
        catch { }
    }