Upgraded to VS2005 now gives an error...

lidds

Well-known member
Joined
Oct 19, 2004
Messages
122
Programming Experience
Beginner
I have just upgraded my project from vs2003 to vs2005, it has gone reletively smoothly and I have cleared all errors apart from one shown below:

VB.NET:
[SIZE=2]myInsertCmd.Parameters.Add([/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] OleDb.OleDbParameter([/SIZE][SIZE=2][COLOR=#800000]"@commImage"[/COLOR][/SIZE][SIZE=2], OleDb.OleDbType.LongVarBinary, b.Length, ParameterDirection.Input, [/SIZE][SIZE=2][COLOR=#0000ff]False[/COLOR][/SIZE][SIZE=2], 0, 0, [/SIZE][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][SIZE=2], DataRowVersion.Current, b))[/SIZE]
[SIZE=2]
[/SIZE]

The above code is to save an image in a sql database, in my vs2003 project the above code was perfectly acceptable and worked fine, however now that I have upgraded to vs2005 it is giving me the following error. Can someone please tell me how to solve this.

Thanks in advance

Simon

Error:

VB.NET:
[/SIZE]
[SIZE=2]Error 1 Overload resolution failed because no accessible 'New' can be called without a narrowing conversion:
    'Public Sub New(parameterName As String, dbType As System.Data.OleDb.OleDbType, size As Integer, direction As System.Data.ParameterDirection, precision As Byte, scale As Byte, sourceColumn As String, sourceVersion As System.Data.DataRowVersion, sourceColumnNullMapping As Boolean, value As Object)': Argument matching parameter 'precision' narrows from 'Boolean' to 'Byte'.
    'Public Sub New(parameterName As String, dbType As System.Data.OleDb.OleDbType, size As Integer, direction As System.Data.ParameterDirection, precision As Byte, scale As Byte, sourceColumn As String, sourceVersion As System.Data.DataRowVersion, sourceColumnNullMapping As Boolean, value As Object)': Argument matching parameter 'scale' narrows from 'Integer' to 'Byte'.
    'Public Sub New(parameterName As String, dbType As System.Data.OleDb.OleDbType, size As Integer, direction As System.Data.ParameterDirection, precision As Byte, scale As Byte, sourceColumn As String, sourceVersion As System.Data.DataRowVersion, sourceColumnNullMapping As Boolean, value As Object)': Argument matching parameter 'sourceColumn' narrows from 'Integer' to 'String'.
    'Public Sub New(parameterName As String, dbType As System.Data.OleDb.OleDbType, size As Integer, direction As System.Data.ParameterDirection, precision As Byte, scale As Byte, sourceColumn As String, sourceVersion As System.Data.DataRowVersion, sourceColumnNullMapping As Boolean, value As Object)': Argument matching parameter 'sourceColumnNullMapping' narrows from 'System.Data.DataRowVersion' to 'Boolean'.
    'Public Sub New(parameterName As String, dbType As System.Data.OleDb.OleDbType, size As Integer, direction As System.Data.ParameterDirection, isNullable As Boolean, precision As Byte, scale As Byte, srcColumn As String, srcVersion As System.Data.DataRowVersion, value As Object)': Argument matching parameter 'precision' narrows from 'Integer' to 'Byte'.
    'Public Sub New(parameterName As String, dbType As System.Data.OleDb.OleDbType, size As Integer, direction As System.Data.ParameterDirection, isNullable As Boolean, precision As Byte, scale As Byte, srcColumn As String, srcVersion As System.Data.DataRowVersion, value As Object)': Argument matching parameter 'scale' narrows from 'Integer' to 'Byte'. C:\Temp\VS\MRCS\frmCommManager.vb 683 44 MRCS

 
I could have sworn that I'd already answered this question.

None of the overloaded method signatures match the types of the values you're passing. I'm guessing that you're intending those zero values to be passed to the Byte arguments, but the values you're passing are Integers. Converting an Integer to a Byte is a narrowing conversion, i.e. data will be lost. The compiler doesn't know about the value itself, only the type. If you want to pass a Byte then pass a Byte. Change those zero values to:

Convert.ToByte(0)
 
Call me what you like, but Upgrading projects using the Conversion Wizard, is not the way to go, ever.
The original project was VB.NET 2003 though, not VB6.
 
The original project was VB.NET 2003 though, not VB6.
Yes, I know :)

The reason why I said that was that, In my personal experience I've found it much better / easier to redo the project in 2005 (if the previous one was 2003) or to redo the project in 2003 if the original project was VB6. By doing it like this, I could tackle the problems as I encounter them, and them fix them.

I'm probably just old fashioned, but I'd rather take the "tough" route than the easier route :)
 
I would never even consider rewriting a .NET 1.1 application if I was upgrading to .NET 2.0 in the vast majority of cases. The types of issues that will arise form upgrading from VB.NET 2003 project to VB 2005 are incredibly minor in comparison to upgrading from VB6. I'd think that at least 75%, and probably more, of the code you would be rewriting would be exactly the same. It's very easy to make changes to VB.NET 2003 code to make use of the new VB 2005 features with minimal impact because the overall structure will change negligibly in most cases. That's in contrast to an upgraded VB6 project that will usually produce code that any decent developer should be ashamed to produce by their own hand. Also, making manual adjustments to the upgraded VB6 code is often tedious because the entire structure will often change considerably.
 
Also note that upgrading a VB.NET 2003 project doesn't change any code at all, just the project and solution files. That means that you will recognise every bit of code in the project, while upgraded VB6 code is often all new and rather confusing.
 
I agree with you 100%! .NET 1.1 is not VB6 (thank Heavens we have all the power we've always wanted!) . And I do agree with you that in the vast majority of cases, rewriting might not be necessary.

The point I'm actually trying to make is that, say for example, I've got an existing .NET 1.1 app, and I want / have to release a new version. With .NET 2.0 I can give the .NET 1.1 app an entire facelift - instead of using (for example) a Menu, ProgressBar, I can upgrade them to Progress Strips etc. I can use TableAdapters in .NET 2.0.

I can optimize my .NET 1.1 code to really make use of the power of the new .NET 2.0 language features such as :
Using
TryCast
Partial Classes
Continue

I can even make use of the My namespace, especially with Resources

I hope you see what I mean :)
No disrespect against you intended, you know, I have respect for you ;)
 
Back
Top