Update error on a recordset ADODB with VB.net - ado

I try-ing to update application but when debugging everything goes well. But updating the records is not working anymore.
The error I get is: System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'
public Sub LoginRegistration()
Dim RSReturn As New ADODB.Recordset
Dim SQLString As String = "SELECT tbllogin.idtbllogin, tbllogin.Log_date, tbllogin.Log_user FROM tbllogin LIMIT 1;"
Try
RSReturn.CursorLocation = ADODB.CursorLocationEnum.adUseClient
RSReturn.CursorType = ADODB.CursorTypeEnum.adOpenDynamic
RSReturn.LockType = ADODB.LockTypeEnum.adLockOptimistic
RSReturn.Open(SQLString, cn)
RSReturn.AddNew()
RSReturn.Fields.Item("Log_date").Value = Now()
RSReturn.Fields.Item("Log_user").Value = "Harold" 'Environment.UserName
RSReturn.Update()
Catch ex As Exception
MsgBox(ex.Message, ex.StackTrace)
Finally
RSReturn.Close()
RSReturn = Nothing
End Try
End Sub```

Related

Google Closure Compile REST Api suddenly Throws Error 405 "Method not allowed"

I've been using Closure as part of y application to compress Javascript for a while now, but just started getting an error 405 - Method not allowed
My code as below was working for a couple of years, but has now stopped.
NOTE: this is not called frequently, just when ever any changes are detected in the Javascript files in my application.
I get no further error information from the Closure app than this.
Obviously this code performs a POST operation. If I use the form found here https://closure-compiler.appspot.com/home, it works, but if I either browser to the URL or use my code I get Error 405, it's almost as if my code is trying a GET method... but it's not...
Any ideas?
Public Class Closure
Property OriginalCode As String
Property CompiledCode As String
Property Errors As ArrayList
Property Warnings As ArrayList
Property Statistics As Dictionary(Of String, Object)
Public Sub New(Input As String, Optional CompliationLevel As String = "SIMPLE_OPTIMIZATIONS")
Dim _HttpWebRequest As HttpWebRequest
Dim _Result As StringBuilder
Dim ClosureWebServiceURL As String = "http://closure-compiler.appspot.com/compile?"
Dim ClosureWebServicePOSTData As String = "output_format=json&output_info=compiled_code" &
"&output_info=warnings" &
"&output_info=errors" &
"&output_info=statistics" &
"&compilation_level=" & CompliationLevel & "" &
"&warning_level=default" &
"&js_code={0}"
'// Create the POST data
Dim Data = String.Format(ClosureWebServicePOSTData, HttpUtility.UrlEncode(Input))
_Result = New StringBuilder
_HttpWebRequest = DirectCast(WebRequest.Create(ClosureWebServiceURL), HttpWebRequest)
_HttpWebRequest.Method = "POST"
_HttpWebRequest.ContentType = "application/x-www-form-urlencoded"
'//Set the content length to the length of the data. This might need to change if you're using characters that take more than 256 bytes
_HttpWebRequest.ContentLength = Data.Length
'//Write the request stream
Using SW As New StreamWriter(_HttpWebRequest.GetRequestStream())
SW.Write(Data)
End Using
Try
Dim response As WebResponse = _HttpWebRequest.GetResponse()
Using responseStream As Stream = response.GetResponseStream
Dim encoding As Encoding = System.Text.Encoding.GetEncoding("utf-8")
Using readStream As New StreamReader(responseStream, encoding)
Dim read(256) As Char
Dim count As Integer = readStream.Read(read, 0, 256)
While count > 0
Dim str As New String(read, 0, count)
_Result.Append(str)
count = readStream.Read(read, 0, 256)
End While
End Using
End Using
Dim js As New JavaScriptSerializer
js.MaxJsonLength = Int32.MaxValue
Dim d As Dictionary(Of String, Object) = js.Deserialize(Of Dictionary(Of String, Object))(_Result.ToString())
Me.CompiledCode = d.NullKey("compiledCode")
Me.Warnings = TryCast(d.NullKey("warnings"), ArrayList)
Me.Errors = TryCast(d.NullKey("errors"), ArrayList)
Me.Statistics = TryCast(d.NullKey("statistics"), Dictionary(Of String, Object))
Catch ex As Exception
Me.CompiledCode = ""
If Me.Errors Is Nothing Then
Dim er As New List(Of String)
er.Add(ex.ToString())
Me.Errors = New ArrayList(er)
Else
Me.Errors.Add(ex.ToString())
End If
End Try
Me.OriginalCode = Input
End Sub
End Class
Closure REST api is redirecting to https, you may want to try to POST to "https://closure-compiler.appspot.com/compile" directly in order to avoid redirection.

LSXLC ODBC Stored Procedure

I'm trying to connect to an Oracle RDB database using LSXLC (ODBC Connector).
But when it comes to stored procedures I'm having a hard time getting it to work.
The code below always results in "Error: Parameter name not supplied: fnl_date, Connector 'odbc2', Method -Call-". The error is triggered on "count = connection.Call(input, 1, result)"
Can anyone tell me what I'm doing wrong?
Public Function testLsxlcProc()
On Error GoTo handleError
Dim connection As LCConnection("odbc2")
connection.Server = "source"
connection.Userid = "userid"
connection.Password = "password"
connection.procedure = "proc_name"
connection.Connect
If connection.IsConnected Then
Dim input As New LCFieldList()
Dim result As New LCFieldList()
Dim break As LCField
Set break = input.Append("fnl_date", LCTYPE_TEXT)
break.Text = "2014-07-01"
Dim agrNo As LCField
Set agrNo = input.Append("fnl_agreement_no", LCTYPE_TEXT)
agrNo.Text = "123456"
Dim curr As LCField
Set curr = input.Append("fnl_currency_code", LCTYPE_TEXT)
curr.Text = "SEK"
Dim stock As LCField
Set stock = input.Append("fnl_stock_id", LCTYPE_TEXT)
stock.Text = "01"
connection.Fieldnames = "status, value"
Dim count As Integer
count = connection.Call(input, 1, result)
Call logger.debug("Count: " & count)
Else
Error 2000, "Unable to connect to database."
End If
handleExit:
connection.Disconnect
Exit Function
handleError:
On Error Resume Next
Call logger.error(Nothing)
Resume handleExit
End Function
Thanks in advance!
I had made a stupid mistake and had a mismatch between the name of the input parameter in Domino and the name of the input parameter in the stored procedure.
Make sure all names match up and there shouldn't be a problem.
Stored-Procedure "mylib.MyStoredProc" wird aufgerufen ...
LcSession.Status = 12325: LC-Error: errCallStoredProc 12325 (Error: Parameter name not supplied: P_S651_AC, Connector 'odbc2', Method -Call-)
Solution: changed "mylib" into "MYLIB" and all was well.
Check not only Parameter-Names, but also the Search-Path.

Flipping image causes massive RAM/CPU uses with AForge.net

Hey all i am trying to figure out why when i flip the image it uses a LOT of RAM and CPU (its an quad core i7)
I use this code:
Dim filter As New RotateBilinear(180, True)
image = Filter.Apply(image)
If bIsToRecord Then
If writer Is Nothing Then
Dim [date] As DateTime = DateTime.Now
Dim fileName As [String] = [String].Format("{0},{1}.avi",[date].Minute, [date].Second)
Try
OpenWriter(fileName, image.Width, image.Height)
Catch ex As Exception
If writer IsNot Nothing Then
writer.Dispose()
writer = Nothing
End If
End Try
End If
Try
If radioButton1.Checked Then
writer.AddFrame(image)
Else
mVideoFileWriter.WriteVideoFrame(image)
End If
Catch ex As Exception
System.Diagnostics.Trace.WriteLine(ex.ToString())
End Try
End If
That is WITHOUT flipping the images
WITH the flipping...
Each screenshot was for 30 seconds.
What could be causing this?

Operation could destabilize runtime, works local, not on server

Here is my Action:
Imports PagedList
<EmployeeAuthorize()>
Function SearchFoods(Optional ByVal date1 As String = "", Optional ByVal keyword As String = "", Optional page As Integer = 1) As ActionResult
If String.IsNullOrEmpty(date1) Then
date1 = Date.Now
End If
If String.IsNullOrEmpty(keyword) Then
keyword = Nothing
End If
Dim food = db.Tbl_Foods.Where(Function(x) x.Shrt_Desc.Contains(keyword)).OrderBy(Function(x) x.Food_ID).ToList
For Each item In food
item.Shrt_Desc = item.Shrt_Desc.Replace(",", ", ")
Next
ViewBag.MyDate = date1
ViewBag.MyKeyword = keyword
' set the page size and number
Dim pageSize = 20
Dim pageNumber = page
TempData("CurrentPage") = "My Wellness"
TempData("CurrentWellnessPage") = "Food Log"
Return View("", "_FinalWellnessSubPageLayout", food.ToPagedList(pageNumber, pageSize))
End Function
I believe this is caused, somehow, by the "ToPagedList" since this is the first time I am using it. It works fine on local, but not when I publish to the server. The stack trace looks like this:
[VerificationException: Operation could destabilize the runtime.]
PagedList.PagedList1..ctor(IEnumerable1 superset, Int32 pageNumber,
Int32 pageSize) +0
PagedList.PagedListExtensions.ToPagedList(IEnumerable`1 superset,
Int32 pageNumber, Int32 pageSize) +62
It also says:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
What is the exception? How can I find what exception "occurred during the execution?"
Does anyone know how to fix this error on the server? Thank you.
I also faced the same problem with IIS 7.5 it was working fine with IIS 6.0 so I reinstalled the Pagedlist package and it worked like a charm.

Why does my stored procedure always think there is a value?

I have an ASP.NET 2010 app hitting a SQL 2005 db. I am attempting to build a stored proc dynamically, depending on the values selected on a search screen. I have done this many times in previosu versions of .net & sql with no problem. However, now, my IF statement always always acts as though no data was passed in. I have debugged the app and am sure that data is being set. I should note that when I run the procedure directly, with or without data, the correct data is returned.
Here is the rather simple stored proc..
ALTER PROCEDURE get_cases_by_search_criteria
#vin as varchar(30) = null
AS
declare #sqlstr varchar(1000)
set #sqlstr = 'SELECT
[Case].CaseID,
[Case].VIN,
[Case].Make,
[Case].Model,
[Case].VehicleYear,
if #vin is not null and #vin <> ''
set #sqlstr = #sqlstr + ' and ' + ('[Case].VIN = ''' + convert(varchar,#vin) + '''')
exec(#sqlstr)
RETURN
And here is the code that calls the stored proc...
Public Function GetCases(ByVal oSearchCriteria As SearchCriteria) As List(Of BE.Case)
Dim lstCase As New List(Of BE.Case)
Dim oCase As BE.Case
Dim oProviderFactory As New ProviderFactory
Dim oConnection As DbConnection
Dim oReader As System.Data.IDataReader
Dim oFactory As DbProviderFactory
Dim oCmd As DbCommand
Dim param1 As System.Data.Common.DbParameter
Try
'call my class to get an instance of the DBProviderFactory class
oFactory = oProviderFactory.GetFactory
'call another class of mine. pass in the DBProviderFactory class which will create a non-provider-specific connection object
oConnection = oProviderFactory.GetProviderConnection(oFactory)
'non-specific create command
oCmd = oConnection.CreateCommand
'non-specific parameter
If oSearchCriteria.VIN.Length = 0 Then
param1 = oFactory.CreateParameter()
param1.ParameterName = "#vin"
param1.DbType = DbType.String
param1.Value = DBNull.Value
oCmd.Parameters.Add(param1)
Else
param1 = oFactory.CreateParameter()
param1.ParameterName = "#vin"
param1.DbType = DbType.String
param1.Value = oSearchCriteria.VIN
oCmd.Parameters.Add(param1)
End If
oCmd.CommandType = CommandType.StoredProcedure
oCmd.CommandText = "get_cases_by_search_criteria"
Using (oConnection)
oConnection.Open()
oReader = oCmd.ExecuteReader()
While oReader.Read
oCase = New BE.Case
'Case
If oReader("CaseID") IsNot System.DBNull.Value Then oCase.CaseID = oReader("CaseID")
If oReader("Make") IsNot System.DBNull.Value Then oCase.Make = oReader("Make")
If oReader("Model") IsNot System.DBNull.Value Then oCase.Model = oReader("Model")
If oReader("VehicleYear") IsNot System.DBNull.Value Then oCase.VehicleYear = oReader("VehicleYear")
If oReader("VIN") IsNot System.DBNull.Value Then oCase.VIN = oReader("VIN")
lstCase.Add(oCase)
End While
oConnection.Close()
End Using
Catch ex As Exception
Throw ex
End Try
Return lstCase
End Function

Resources