Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > BOOK: Beginning VB.NET Databases
|
BOOK: Beginning VB.NET Databases
This is the forum to discuss the Wrox book Beginning VB.NET Databases by Thearon Willis; ISBN: 9780764568008
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning VB.NET Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 7th, 2005, 10:42 PM
Authorized User
 
Join Date: Aug 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Uniqueidentifier to Integer Conversion

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
 
Old August 8th, 2005, 04:24 AM
Thearon's Avatar
Wrox Author
 
Join Date: Dec 2003
Posts: 396
Thanks: 0
Thanked 8 Times in 8 Posts
Default

Mark,

In addressing your issue, I'll make two assumptions. First, the Tag property in your ListView control does indeed contain an Integer value. Second, the User table that you are using also contains an Integer value.

A quick observation of your code in the GetUser function indicates that you should be passing the UserID parameter to the AddParameter method instead of prim so your code reads like this:

MyBase.AddParameter(“@UserID”, _
      SqlDbType.Int, _
      4, UserID)

I hope this helps.

Thearon
 
Old August 8th, 2005, 06:57 PM
Authorized User
 
Join Date: Aug 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, Thearon. Are you willing to provide some paid e-mail support for me as I modify the application? Since I'm a beginner, I could use a little more support.

Mark





Similar Threads
Thread Thread Starter Forum Replies Last Post
Is uniqueidentifier is always unique ? vinod_yadav1919 SQL Server 2000 4 May 30th, 2008 11:31 AM
Integer I/O in assembly kaycg BOOK: Professional Assembly Language 2 May 11th, 2007 05:00 AM
Use of UNIQUEIDENTIFIER ggandta BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 2 March 9th, 2007 01:52 PM
text vs integer paul20091968 Access VBA 2 February 13th, 2007 10:50 PM
integer overflow partaola Beginning VB 6 2 March 17th, 2004 09:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.