我有一种使用查询更新MySQL表的方法.我正在使用MS Visual Studio和phpmyadmin作为SQL客户端.
Hi I have a method which updates a MySQL table using a query. I'm using a MS Visual Studio and phpmyadmin as the SQL client.
方法:
public static Member updateMember(string un, string pass, string name, string surname, string mf, string dob, string add, string phone, string email) { MySqlConnection connection = new MySqlConnection(conn); MySqlCommand cmd; string query = "UPDATE MEMBER SET Name='" + un + "', Surname='" + surname + "', MF='" + mf + "', DOB='" + dob + "', Address='" + add + "', PhoneNo='" + phone + "', EMail='" + email + "', UserName='" + un + "', Password='" + pass + "' "; tr y { connection.Open(); cmd = connection.CreateCommand(); cmd.CommandText = query; cmd.ExecuteNonQuery(); } catch (Exception) { throw; } finally { if (connection.State == System.Data.ConnectionState.Open) { connection.Close(); } } }这是正在发生的事情.我将文本框中的某些值以字符串变量的形式存储.然后,我将这些字符串变量发送到此方法.我希望该方法可以捕获我的字符串变量,并使用变量的值更新我的SQL表.
Here is what's happening. I'm storing some values from TextBoxes in a form in string variables. Then I'm sending those string variables to this method. I want that this method grabs my string variables and update my SQL table with the values of my variables.
我遇到错误,并非所有代码路径都返回值.
I'm getting an error not all code paths return a value.
推荐答案您的方法未返回任何内容,您需要返回成员对象.
Your method is not returning anything, You need to return the Member Object.
如果您不需要返回任何内容,只需像这样更改您的方法签名,
If you do not need to return anything , just change your Method Signature like this,
public static Void updateMember(string un, string pass, string name, string surname,string mf, string dob, string add, string phone, string email)更多推荐
得到异常“并非所有代码路径都返回值".
发布评论