Iâm getting a "Type âIntegerâ has no constructors" error with the conversion of a uniqueidentifier to an integer column datatype in a
VB .Net app using SQL Server 2000.
In the Time Tracker application, the Users table uses the uniqueidentifier for the primary key. My database table uses an Integer primary key.
The purpose of the modified method is to select a Recipe and display data from the associated fields.
Any assistance would be appreciated.
Thanks,
Mark
Form: Admin (p. 409)
' ***************************************
' In the Admin form "LoadItems" method
' Original Admin form
' ***************************************
'Get the specific User in ListView control
objDataset = objUsers.GetUser( _
New Guid(lvwUsers.SelectedItems.Item(0).Tag.ToString))
Class: WDAUsers (original Wrox App -- p. 402)
' ***************************************
' Original GetUser Method
' ***************************************
Public Function GetUser(ByVal UserID As Guid) As DataSet
Try
GetUser = New DataSet
'Initialize a new instance of the Crypto class
MyBase.Crypto = New WDACrypto(CryptoKey, CryptoIV)
MyBase.SQL = âusp_SelectUserâ
'Initialize the Command object
MyBase.InitializeCommand()
'Add a Parameter to the Parameters collection
MyBase.AddParameter(â@UserIDâ, SqlDbType.UniqueIdentifier, _
16, UserID)
'Fill the DataSet
MyBase.FillDataSet(GetUser, âUserâ)
'Decrypt the password
GetUser.Tables(âUserâ).Rows(0).Item(âPasswor dâ) = _
MyBase.Crypto.Decrypt( _
GetUser.Tables(âUserâ).Rows(0).Item(âPasswor dâ))
Catch ExceptionErr As Exception
Throw New System.Exception(ExceptionErr.Message, _
ExceptionErr.InnerException)
Finally
MyBase.Crypto.Dispose()
MyBase.Crypto = Nothing
End Try
End Function
In the Admin form "LoadItems" method
' ***************************************
' Modified
' ***************************************
objDataset = objItem.GetRecipe( _
New Integer(lvwItem.SelectedItems.Item(0).Tag.ToString ))
/ **** Results in the following error: ***********/
Type âIntegerâ has no constructors
"BLItemTable" class
' ***************************************
' Modified GetUser Method
' Renamed as the GetRecipe method
' ***************************************
Hereâs the modified GetUser method:
Public Function GetRecipe(ByVal UserID As Integer) As DataSet
Try
GetUser = New DataSet
MyBase.SQL = âSelectUserâ
' initialize command
MyBase.InitializeCommand()
' add parameter
MyBase.AddParameter(â@UserIDâ, _
SqlDbType.Int, _
4, prim)
' fill the dataset
MyBase.FillDataSet(GetUser, âtblUserâ)
Catch
Catch exceptionErr As Exception
Throw New System.Exception(exceptionErr.Message, _
exceptionErr.InnerException)
End Try
End Function