私はあなたのexecSQL()
メソッドがどのように構築されているのかよく分かりませんが、通常ではなく、まったく問題なく、SQLクエリ文字列に変数データを直接代入することもできます。それはあなたのプログラムをハッキングする良い方法です。代わりに、サーバーにデータを受け入れて別々に送信するメカニズムが必要です。それは多くの場合、このようなものになります。
Public Sub execSQL(ByVal SQL As String, Optional ByVal ParamArray QueryParameters() As MySqlParameter)
Using cn As New MySqlConnection("connection string here"), _
cmd As New MySqlCommand(SQL, cn)
If QueryParameters IsNot Nothing Then
For Each p As MySqlParameter In QueryParameters
'This does NOT EVER do string manipulation to set the data into the query
' Instead, it's sent to the server in a separate data section, where the variables are setup.
' In this way, data stays separate from code, and any possibility of sql injection is prevented.
cmd.Parameters.Add(p)
Next
End If
cn.Open()
cmd.ExecuteNonQuery()
End Using
End Sub
をして、あなたはこのようにそれを呼び出す:私はパラメータを照会するために切り替えることも厄介なフォーマットや構文の問題を修正し、多くの例を見てきました
Public Sub Code(ByVal dte As DateTime)
Dim strSQl As String = "Update tblTenant Set dte = @dte blablalbla"
Dim dteParam As New MySqlParameter("@dte", MySqlDbType.DateTime)
dteParam.Value = dte
Me._Inst.execSQL(strSQl, dteParam)
End Sub
十分なので、ここでクエリパラメータを使用すると、あなたの質問を促した問題が解決される可能性が高いです。
どのような列の種類ですか? –
これはSQLインジェクション攻撃に対して脆弱です。 –
SQLパラメータを使用して、 'DateTime'を' DateTime'として渡します。そのコードはテキストを渡して、DBプロバイダに問題を解決させるものです。 – Plutonix