我将以下代码行转换为C#.
//VB Code:
Dim Query As String = "UPDATE Lidhja_Sh_A_M SET Id_A=@Id_A, Id_Sh=@Id_Sh, Id_M=@Id_M WHERE Id_L=@Id_L"
Dim cmd As SqlCommand = New SqlCommand(Query, con)
cmd.Parameters.AddWithValue("@Id_A", Trim(Me.txbIDLA.Text))
cmd.Parameters.AddWithValue("@Id_Sh", Trim(Me.txbIDLSh.Text))
cmd.Parameters.AddWithValue("@Id_M", Trim(Me.txbIDLM.Text))
Run Code Online (Sandbox Code Playgroud)
// C# code with error
cmd.Parameters.AddWithValue("@Id_A", Strings.Trim(this.txbIDLA.Text));
cmd.Parameters.AddWithValue("@Id_Sh", Strings.Trim(this.txbIDLSh.Text));
cmd.Parameters.AddWithValue("@Id_M", Strings.Trim(this.txbIDLM.Text));
Run Code Online (Sandbox Code Playgroud)
C#代码中的问题在哪里?
你不能Trim在c#中使用这样的方法.你必须在string实例上调用它,例如:
cmd.Parameters.AddWithValue("@Id_A", this.txbIDLA.Text.Trim());
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
293 次 |
| 最近记录: |