Wrox Programmer Forums
|
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 November 7th, 2006, 12:25 AM
Authorized User
 
Join Date: Aug 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thearon,

Yes. Here are the queries I am using:

usp_DeleteLease

DELETE *
FROM Leases
WHERE LeaseID = @LeaseID;


usp_InsertLease

INSERT INTO Leases ( LeaseID, Branch, Due-
Date, StartDate, EndDate, BranchID, LandlordID)
VALUES (@LeaseID, @Branch, @DueDate, @
StartDate, @EndDate, @BranchID, @LandlordID);


usp_UpdateLease

UPDATE Leases SET Branch = @Branch, Due-
Date = @DueDate, StartDate=@StartDate, End-
Date = @EndDate, BranchID = @BranchID,
LandlordID = @LandlordID
WHERE LeaseID = LeaseID;


usp_InsertBranch

INSERT INTO Branches ( BranchID, brName )
VALUES (@BranchID, @brName);

I'm able to insert, update, and delete data using text boxes. Here is some code from the update routine:

                objData.SQL = "usp_UpdateLease"
                    'Initialize the Command object
                    objData.InitializeCommand()

                    'Add Lease primary key
                    objData.AddParameter("@LeaseID", _
                       OleDb.OleDbType.Guid, 16, New Guid(txtUserID.Text))

                    objData.AddParameter("@Branch", _
                                            OleDb.OleDbType.VarChar, 50, txtLogin.Text)
                    objData.AddParameter("@DueDate", _
                       OleDb.OleDbType.VarChar, 10, txtFirstName.Text)
                    objData.AddParameter("@StartDate", _
                        OleDb.OleDbType.VarChar, 10, txtEmail.Text)
                    objData.AddParameter("@EndDate", _
                        OleDb.OleDbType.VarChar, 10, txtPassword.Text)

Mark
 
Old November 8th, 2006, 06:07 PM
Thearon's Avatar
Wrox Author
 
Join Date: Dec 2003
Posts: 396
Thanks: 0
Thanked 8 Times in 8 Posts
Default

Mark,

You parameters are odd. Are you really trying to set a due date using the first name of a user? Anyway, try this; ensure that the parameters are added in the same order in your code as they are specified in your query.

Thearon
 
Old November 15th, 2006, 03:12 PM
Authorized User
 
Join Date: Aug 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thearon,

After changing the code so that it is in the same order as the parameters, the value from the Branches combo box does pass to the Leases table.

There are two combo boxes used in the UpdateLeases procedure: Branches and Landlords. I also tested the Landlords combo box. This combo box also functions properly -- the correct value does pass to the Leases table.

Here's the code for the Landlords combo box:

                    objData.AddParameter("@LandlordID", _
                       OleDb.OleDbType.Guid, 16, cboUserRole.SelectedItem.item("LandlordID"))

An error occurs with the value displayed in the combo boxes. After a lease item is clicked, the value in both combo boxes does not reflect the value in the Leases table.

An error occurs after resetting the selected index of the Landlords combo box (still in the UpdateLeases procedure).

After the following line of code to reset the Landlords combo box (cboUserRole) is executed, the value of "cboUserRole.SelectedItem.item("LandlordID")" no longer reads "{System.Guid}":

cboUserRole.SelectedIndex = -1

The value of "cboUserRole.SelectedItem.item("LandlordID")" changes to:

cboUserRole.SelectedItem.item("LandlordID") Run-time exception thrown : System.NullReferenceException - Object variable or With block variable not set.

Here's the code used to reset both combo boxes:

                'Clear ComboBoxes
                    'Reset the selected index
                    cboUserGroup.SelectedIndex = -1
                    cboUserRole.SelectedIndex = -1

The value of the Branches combo box (" cboUserGroup.SelectedItem.item("BranchID")") remained "{System.Guid}" after the selected index of the Branches combo box was reset.

The answer to your question about using the first name of a user is no. I haven't had a chance to change the name of the text box controls yet.

Mark
 
Old November 24th, 2006, 04:12 PM
Authorized User
 
Join Date: Aug 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for your help.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Malformed GUID Error runtime 3075 awesomejohn Access VBA 2 October 1st, 2007 08:27 AM
Guid Error in listview click event Jimson BOOK: Beginning VB.NET Databases 9 February 16th, 2006 01:57 PM
MS Access Unknown Error mrahman Beginning VB 6 2 February 9th, 2006 03:31 AM
MS ACCESS Error 3343 Manuelaucho VB Databases Basics 0 November 14th, 2005 01:12 PM
MS Access and VBA Error Diahann Access VBA 10 January 7th, 2005 05:46 PM





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