I am getting this error:
System.Data.SqlServerCe.HashSafeHandle" could not release handle with value 0x08D7E430
suddenly using
System.Data.SqlServer_Ce_unofficial
and then calling this simple function (which worked all the time):
Using nCmdSel As SqlServerCe.SqlCeCommand = uCn.CreateCommand
With nCmdSel
.CommandText = uCommandText
End With
Dim r As SqlServerCe.SqlCeDataReader = nCmdSel.ExecuteReader
Return r
End Using
Does anybody have any idea why?
Related
I am trying to add an item to a List. However everytime I try to add something to that list I face an ArrayTypeMismatchException error with the error message being "Attempted to access an element as a type incompatible with the array".
Dim params as New List(of OracleParameter)
params.Add(OracleParameterFactory.CreateIn(usedId, OracleDbType.Varchar2))
The method "CreateIn" has a return type of OracleParameter. I'm not sure why I'm getting this error at all. Any help will be much appreciated.
Here's the definition for CreateIn
Public Shared Function CreateIn(ByVal name as String, ByVal type as OracleDbType) As OracleParameter
Dim p as New OracleParameter()
p.ParameterName = name
p.Direction = ParameterDirection.Input
p.OracleDbType = type
If type = OracleDbType.Varchar2 Then
p.Size = 4000
End If
p.Value = DBNull.Value
Return p
End Function
The same definition and implementation is working in another application without issue if that's any help.
Till now I have cleaned and rebuilt the solution, removed the System library from the project, manually deleted the bin and obj folders but nothing has yet fixed the problem.
I have usual peace of code for VB.NET, such this:
Dim ds = New DataSet
Using mCon As NpgsqlConnection = dbUtil.getConnection()
Using t As NpgsqlTransaction = mCon.BeginTransaction()
... some code ...
t.Commit()
End Using
End Using
With this code I have in "mCon.BeginTransaction()" mCon underlined with green and warning message is "Variable 'mCon' is used before it has been assigned a value. A null reference exception could result at runtime".
Why is that and how to get rid of this?
My code is as follows:
Using _EntityModel As New AboveNemaSalesDatabaseEntities()
Dim _SelectActiveOptionCodes = (From _OptCodes In _EntityModel.tblOptionCodes
Where _OptCodes.fdStatus = "A"
Select _OptCodes.fdDescription, _OptCodes.fdOptionCode).ToList()
Dim _SelectActiveOptionCodes2 = (From _OptCodes In _EntityModel.tblOptionCodes
Where _OptCodes.fdStatus = "A"
Select New optionCodes With {.description = _OptCodes.fdDescription,
.optionCode = _OptCodes.fdOptionCode})
sortableOptionCodes = _SelectActiveOptionCodes2
sortedOptionCodes = _SelectActiveOptionCodes2
OptionCodeListBox.DataSource = sortedOptionCodes
OptionCodeListBox.DisplayMember = "fdDescription"
OptionCodeListBox.ValueMember = "fdOptionCode"
End Using
The first query works fine and returns a list in the format [index]{description = "descritption here", optionCode = "option code here"}
The second query creates but when it is called to save to my custom class the program exits the sub or swallows an error. Stepping through the code, the line starting with sortedOptionCodes and after never runs.
The main issue I was dealing with is that my query was producing a list of optionCodes and my variable was not prepared to store this.
Old variables:
Dim sortableOptionCodes As optionCodes
Dim sortedOptionCodes As optionCodes
New variables:
Dim sortableOptionCodes As List(Of optionCodes)
Dim sortedOptionCodes As List(Of optionCodes)
I also added a .ToList() function to the end of the second query.
I made a Class Module and named it Time. I wanted to have a function in it that created an instance of the Time object and returned it. See code below. If you can think of a better way to write the function, I'm all ears. The problem I'm having, as it stands is when I make the following statement:
tsheet.MondayStart = Time.Construct(Item.Value)
A debug.print statement prior to this call shows that Item.Value is "08:30".
tsheet is of type TimeSheet and MondayStart property is expecting to be assigned an object of type Time. However, when this statement executes at runtime, I get the object required error. I even tried removing the paranthesis, but all that does is bring up another error "Compile Error: Expected end of statement"
How do I fix this? Please advise. Too bad vba doesn't support the notion of construtors :-(
Alan
'IN TIME CLASS MODULE
Public Function Construct(Value As String) As Time
'This function expects a string formatted like: 08:30
'Time.Delimiter returns ":"
Dim tempTime As Time
Dim vhours As Integer
Dim vminutes As Integer
Dim arrTime() As Time
arrTime = Split(Value, Time.Delimiter)
hours = CInt(Trim(arrTime(0)))
minutes = CInt(Trim(arrTime(1)))
Set tempTime = New Time
tempTime.hours = vhours
tempTime.minutes = vminutes
Construct = tempTime
End Function
Actually I suggest you use the already implemented VBA methods DateValue and TimeValue which will accept a string and give you what you need.
I am not sure you need to re-invent the wheel here. Of course I might have missed something so please let me know.
Use the result of the new as follows:
Set MonStart = New TimeFrame
Set tsheet.MondayStart = MonStart.Initialize(MonStart, Item.Value)
(For comparision, here's previous:
Set MonStart = New TimeFrame
Set tsheet.MondayStart = TimeFrame.Initialize(MonStart, Item.Value)
)
Also use Set on function return value assignment.
for the first code example:
...
Set Construct = tempTime
End Function
and for the other code example:
...
Set Initialize = Value
End Function
I am using threads to read from a file and process content. I have the following code:
Dim line As String = Nothing
Dim result As String = Nothing
Dim solved As Boolean
While strReader.EndOfStream <> True
SyncLock strReader
line = strReader.ReadLine()
result = "ERROR"
End SyncLock
solved = False
While solved = False
result = Process(line)
If Not result.Contains("ERROR") Then
solved = True
End If
End While
//some code
End While
and it gives me that error at line: If Not result.Contains("ERROR") Then
with labels works fine but I read that they are bad for coding.
How can I get rid of this error? What am I doing wrong?
Thanks!
The error pretty much says it all
Process(line)
Is returning a null value. Fix Process() to return a non-null value.
Alternately you could do this
If not result is nothing then
solved = not result.Contains("ERROR")
End if