Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim CommId As String = q("CommId")
Dim Comment As New Comment
Dim conditionValue As New NameValueCollection
conditionValue("id") = CommId
If (ReContent_Input.Text = "") Then
Comment.Entity.Rec
Else
Comment.Entity.Recontent = ReContent_Input.Text
End If
If Comment.Update(conditionValue) > 0 Then
Tools.JsExe("更新成功!", "WebComment.aspx", 2)
Else
Tools.Alert("更新失败!", 1)
End If
End Sub
上面代码中当Recontent_Input.text出现空值时则不更新且出现错误:
<ErrorLog Date="2009-05-25">
<ErrorTime Value="4:24">
<Method>ExecuteNonQuery</Method>
<Parames>[fieldName=System.Collections.Specialized.NameValueCollection;fieldValue=;strSql=System.Collections.ArrayList;conditionValue=;tableName=System.Collections.ArrayList;dbAction= where
id=@id ;]</Parames>
<ErrorMsg>关键字 'where' 附近有语法错误。</ErrorMsg>
<Trace> 在 System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
在 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
在 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
在 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
在 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
在 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
在 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
在 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
在 System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
在 Winson.Framework.DBProviders.DBProvider.ExecuteNonQuery(DBAction dbAction, String tableName, String strSql, ArrayList fieldName, ArrayList fieldValue, NameValueCollection conditionValue) 位置 g:\个人设计\CodeItem\Winson.Framework\DBProviders\DBProvider.cs:行号 110</Trace>
</ErrorTime>