|
The code from my version (slightly tidied up) looks like:
public override long GetChars(int i, long fieldOffset, char[] buffer2, int bufferoffset, int length)
{
return this._columnInfo[i].GetChars(this._buffer, fieldOffset, buffer2, bufferoffset, length);
}
internal long GetChars(NativeBuffer_RowBuffer buffer, long fieldOffset, char[] destinationBuffer, int destinationOffset, int length)
{
int result;
if (this.IsLob)
{
using (OracleLob oracleLob = new OracleLob(this._lobLocator))
{
string str = (string) oracleLob.Value;
int length1 = str.Length;
int startIndex = (int)fieldOffset;
result = length1 - startIndex;
if (destinationBuffer != null)
{
result = Math.Min(result, length);
if (0 < result) Buffer.BlockCopy(str.ToCharArray(startIndex, result), 0, destinationBuffer, destinationOffset, result);
}
}
}
else
{
}
return (long) Math.Max(0, result);
}
public object Value
{
get
{
long num = this._currentPosition;
try
{
this.Seek(0L, SeekOrigin.Begin);
if (this._lobType == OracleType.Blob || this._lobType == OracleType.BFile)
{
}
return new StreamReader(this, Encoding.Unicode).ReadToEnd();
}
finally
{
this._currentPosition = num;
}
}
}
So basically:
- The
OracleLob.Value property reads the entire CLOB value into memory as a string; - The
OracleColumn.GetChars method calls ToCharArray which copies (a portion of) the string to a new array; - It then uses
Buffer.BlockCopy to copy the characters from the new array to the destinationBuffer array;
It's not quite as bad as I thought - it's only copying a portion of the string to a new array when it calls ToCharArray , rather than the whole string.
But it's still pretty bad compared to using a StreamReader over the OracleLob object.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
..if a string is large enough, it will be thrown into the large object heap?
Ouch
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hello !
On my application I use the
System.Windows.Forms.OpenFileDialog
System.Windows.Forms.FolderBrowserDialog
But on these default windows there are some buttons or labels that are in English. Is there any possibility to access and rename these in anther language ?
Thank you !
|
|
|
|
|
They are determined by the system, and react to the systems settings. It would be possible, but it won't be easy. There are some articles on customizing the OpenFileDialog here on CodeProject.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Any link to these articles ?
|
|
|
|
|
|
Hello !
I'm using the .net 4.5 compression library.
I can create .zip files from my program , and also I can get zip files to do several actions with files inside.
The problem is this :
I want to detect if the zip file is the one created from my application , or is another zip file.
Is there any way to add a validation information ( so a hidden information ) inside a zip file so I can detect this ?
Thank you !
|
|
|
|
|
You can add something, but not hide it. You could encrypt the information and deduce that it cannot be yours, but I could also copy that part into a new zipfile.
You "could" add a text-file that gets zipped; fill it with checksum for each file, adding salt that is unique to your application. That would provide "some" guarantee that it was a file created by your application; I'd need to hack into the code to find out how to build one that looks like it.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
The .ZIP format allows to extra data (metadata) to be added to the archive and to each file.
The classes in the .NET Framework do NOT support this.
You have to use a third party library to do this, like DotNetZip or SharpZipLib. Using either those libraries will let you add data to each file as a "comment". So long as your data can be represented as a string, it'll work.
|
|
|
|
|
Hello !
I have followed your suggestions , and I'm using comments inside the zip file. But the problem is that some programs like 7Zip can make this comment visible , and also let the users add comments. So a file created with this program can add comments and a zip file that seems created with my software , may be created with this other software.
What can I do ?
Thank you !
|
|
|
|
|
I never said the solution was perfect.
Yes, all comments are visible in just about any ZIP program.
Metadata is supported in the ZIP format outside of comments. The problem is I don't know of a single ZIP library that supports it. You'd have to write your own ZIP library to do this and that's a HUGE undertaking.
|
|
|
|
|
I have some SQL Linq that I need date ranges for. But I remember when I wrote them in TSQL, I had to specify the hours, minutes and seconds to compare to a DateTime Column.
So I have this for the current day, not that hard to figure this one out.
Dim DateStart As New DateTime(Now.Year, Now.Month, 1, 0, 0, 0, 0)
Dim DateStop As New DateTime(Now.Year, Now.Month, DateTime.DaysInMonth(Now.Year, Now.Month), 23, 59, 59, 0)
I wrote this for Last Months first and last day, but I only get the date, and not the time
This one is harder to figure out.
Dim DateStart As DateTime = DateAdd("m", -1, DateSerial(Year(Today), Month(Today), 1))
Dim DateStop As DateTime = DateAdd("m", 0, DateSerial(Year(Today), Month(Today), 0))
I wrote this for last years first day and last day, but once again I only get the date
Dim DateStart As DateTime = DateAdd("y", -1, DateSerial(Year(Today), Month(Today), 1))
Dim DateStop As DateTime = DateAdd("y", 0, DateSerial(Year(Today), Month(Today), 0))
I haven't written complex date and time in vb, only in TSQL and I had to get help on that as well. I could use some help or a nudge on this to get going in the right direction.
|
|
|
|
|
Then easy way to do it is to just assemble the DateTime from Month, Day 1, Year, 00:00:00 (midnight), like you have in your first line of code.
The end DateTime is actually very easy. Just create a DateTime for the Month + 1, Day 1, Year, 00:00:00 (midnight).
For example,
' Get the current Date/Time in a variable we can manpulate consistently
' This is because each call to DateTime.Now or DateTime.Today will return
' a different time, and if executed at midnight, different days!
Dim baseDate As DateTime = DateTime.Today()
' Build a start date based on the current month and year.
Dim startDate As DateTime = New DateTime(baseDate.Year, baseDate.Month, 1, 0, 0, 0, 0)
' Build a end date based on the current month and year.
' Add a month to the current DateTime to easier get the end date.
' This also accounts for rolling over the year.
baseDate = baseDate.AddMonth(1)
Dim stopDate = New DateTime(baseDate.Year, baseDate.Month, 1, 0, 0, 0, 0)
Now, in your query the WHERE clause would look like this:
WHERE dateTime >= startDate AND dateTime < endDate
This accounts for records that appear from midnight on the start day and up to, but not inclusive of, the end date which starts at midnight.
|
|
|
|
|
Thanks Dave, I'll give that a try. I need to build some data up in order to fully test it.
But I did write this for last month and last year, but wasnt' able to fully test it.
Dim DateStart As DateTime = DateAdd("m", -1, DateSerial(Year(Today), Month(Today), 1))
Dim DateStop As DateTime = DateAdd("m", 0, DateSerial(Year(Today), Month(Today), 0))
Dim DateStart As DateTime = DateAdd("yyyy", -1, DateSerial(Now.Year, 1, 1))
Dim DateStop As DateTime = DateAdd("yyyy", -1, DateSerial(Now.Year, 12, 31))
|
|
|
|
|
I would also, like Dave, first calculate my baseDate and after this working with this variable.
It allows you a little bit easier Debugging and result-checking ...
|
|
|
|
|
The DateAdd and DateSerial functions are VB-specific methods intended to provide some level of backwards-compatibility with VB6. They're not particularly efficient, and don't offer anything that the built-in methods on the DateTime type can't do. You should try to avoid using them in any new code.
There's a slight quirt with DateSerial where the month and day parameters can be outside of the valid range - for example, your DateStop passes 0 as the day parameter. If required, you can replicate this behaviour by starting with the 1st January and adding the months and days:
DateSerial(year, month, day)
New DateTime(year, month, day)
New DateTime(year, month, 1).AddDays(day - 1)
New DateTime(year, 1, 1).AddMonths(month - 1).AddDays(day - 1)
For DateAdd , the equivalent depends on the date interval you're adding:
dateValue.AddYears(number)
dateValue.AddMonths(number * 3)
dateValue.AddMonths(number)
dateValue.AddDays(number)
dateValue.AddDays(number * 7)
dateValue.AddHours(number)
dateValue.AddMinutes(number)
dateValue.AddSeconds(number)
For the periods you're using:
Dim todayStart As DateTime = DateTime.Today
Dim todayEnd As DateTime = todayStart.AddDays(1).AddSeconds(-1)
Dim monthStart As New DateTime(DateTime.Today.Year, DateTime.Today.Month, 1)
Dim monthEnd As DateTime = monthStart.AddMonths(1).AddSeconds(-1)
Dim yearStart As New DateTime(DateTime.Today.Year, 1, 1)
Dim yearEnd As DateTime = yearStart.AddYears(1).AddSeconds(-1)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I didn't know that about DateSerial, it was giving me strange behavior.
I'll rewrite my code to use addMonths, addYears, etc.
And your samples give me strong examples to reference.
Thanks Dave!
|
|
|
|
|
I am developing a Windows Forms application with Visual Studio 2010 and VB.net.
On the "load" of a form I inserted the following code that takes data from a Firebird DB and I would populate a "datagridview" but I can not:
Private Sub Form1_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
Try
Dim cn As New OdbcConnection("dsn=PHOENIXDB;uid=SYSDBA;pwd=masterkey;")
Dim mystring As String = "Select * from VW_SSN_REGIONI"
Dim cmd As OdbcCommand = New OdbcCommand(mystring)
Dim daSSNregioni As New OdbcDataAdapter
Dim dsSSNregioni As New DataSet
cn.Open()
daSSNregioni.SelectCommand = cmd
daSSNregioni.SelectCommand.Connection = cn
daSSNregioni.Fill(dsSSNregioni, "SSN_REGIONI")
Me.DataGridViewX1.DataSource = dsSSNregioni
cn.Close()
Catch ex As NullReferenceException
MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OkOnly, "Connection Error !!")
Catch ex As Exception
MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OkOnly, "Connection Error !!")
End Try
End Sub
Thanks
|
|
|
|
|
change
Me.DataGridViewX1.DataSource = dsSSNregioni
to
Me.DataGridViewX1.DataSource = dsSSNregioni.Tables(0)
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Thanks.... all ok
|
|
|
|
|
Attempted to read or write protected memory. This is often an indication that other memory is corrupt in vb.net
|
|
|
|
|
You probably have some parameter mismatch in some P/Invoke function call. But since you decided not to share any kind of information about your code, or where the error is occurring, we can only guess.
You can lead a developer to CodeProject, but you can't make them think.
The Theory of Gravity was invented for the sole purpose of distracting you from investigating the scientific fact that the Earth sucks.
|
|
|
|
|
Considering that there is about a thousand different causes for an error like this, it's impossible to tell you anything useful without a lot more information from you.
|
|
|
|
|
This is a stumper.
In my SQL Linq, I Projected the results into a class in IEnumerable(of Class)
One of the columns is ResponseDate, Which is a DateTime in the class I project into,
a DateTime in the Model
But on the VB Side, but I go to use the class as an Object
For m As Object in Messages
.Text = m.ResponseDate.ToString("MM/dd/yy H:mm")
is not a valid integer.
This I get is not a valid DateTime
.Text = DateTime.ParseExact(m.ResponseDate, "MM/dd/yy H:mm", CultureInfo.InvariantCulture)
I'm not sure what to think on this. I thought by projecting into the class, that it would keep it's type and cast correctly.
|
|
|
|
|
The problem is you told VB to treat m as an Object, which doesn't have a ResponseDate property.
|
|
|
|
|