Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 6th, 2006, 11:14 AM
Authorized User
 
Join Date: Mar 2006
Location: , , .
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default Database does not update, no exception thrown

Im using a dataadapter and dataset in an Employee Class to perform updates. The code runs a select stored procedure to select the employee, and an update SP to update the information. I can run the update SP from server explorer and it will update the database table successfully, but not from the program.

here is the code to send the changes to the DB:
'oEmployee is an instance of Employee
'employeeDA is the DataAdapter
'SELECTED is the Dataset


 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'Update the Employee in the Database



        Try
            oEmployee.EmployeeDA.UpdateCommand.Parameters.Add( "@EmployeeID", oEmployee.EmployeeID)
            oEmployee.EmployeeDA.UpdateCommand.Parameters.Add( "@ParkingID", oEmployee.ParkingID)
            oEmployee.EmployeeDA.UpdateCommand.Parameters.Add( "@PermitNumber", oEmployee.PermitNumber)
            oEmployee.EmployeeDA.UpdateCommand.Parameters.Add( "@PermitReturn", oEmployee.PermitReturn)
            oEmployee.EmployeeDA.UpdateCommand.Parameters.Add( "@BadgeID", oEmployee.BadgeID)
            oEmployee.EmployeeDA.UpdateCommand.Parameters.Add( "@BadgeReturn", oEmployee.BadgeReturn)
           oEmployee.EmployeeDA.UpdateCommand.Parameters.Add( "@Credential", oEmployee.Credential)

        oEmployee.EmployeeDA.Update(oEmployee.SELECTED)


        Catch eInsertException As Exception
            MsgBox(eInsertException.ToString, MsgBoxStyle.OKOnly)
            Throw eInsertException
        Finally
            Splatgirl.Close()
        End Try
        SelectedEmployee.Dispose()
        SelectedEmployee = Nothing
        Splatgirl.Close()
        MsgBox("Employee updated", MsgBoxStyle.OKOnly, "Update Complete")
        Me.Refresh()
        Me.Close()


    End Sub


Here is a listing of the update SP:

CREATE PROCEDURE [dbo].[UpdateEmployeeCS]


(
    @EmployeeID uniqueidentifier,
    @ParkingID char(10),
    @PermitNumber char(10),
    @PermitReturn char(10),
    @BadgeID char(10),
    @BadgeReturn char(10),
    @Credential char(10)

)

AS


UPDATE Employees SET

     [Permit Number] = @PermitNumber,
     [Parking ID] = @ParkingID,
     [Permit Return] = @PermitReturn,
     [Badge ID] = @BadgeID,
     [Badge Return] = @BadgeReturn,
     Credential = @Credential

WHERE (EmployeeID = @EmployeeID)
GO



This is the function that sets up the DataAdapter

 Public Function GetData(ByVal empLname As String, ByVal empFname As String) As String
        Me.SPLATGIRL = New SqlConnection("workstation id=D5WQ1K81;packet size=4096;integrated security=SSPI;data source=SPLATGIRL;persist security info=False;initial catalog=MWPH Employee Processing")

        Me.EmployeeDA = New SqlDataAdapter("SelectedEmployee", SPLATGIRL)
        Dim dr As DataRow
        Dim DAUpdateCmd As New SqlCommand
        With DAUpdateCmd
            .CommandType = CommandType.StoredProcedure
            .CommandText = "UpdateEmployeeCS"
            .Parameters.Add("@EmployeeID", EmployeeID)

            .Connection = SPLATGIRL
        End With
        EmployeeDA.UpdateCommand = DAUpdateCmd
        With EmployeeDA
            .TableMappings.Add("Employees", "SELECTED")
            .MissingSchemaAction = MissingSchemaAction.AddWithKey
            .SelectCommand.CommandType = CommandType.StoredProcedure
            .SelectCommand.Parameters.Add("@LastName", empLname)
            .SelectCommand.Parameters.Add("@FirstName", empFname)
            .FillSchema(SELECTED, SchemaType.Source)
            .Fill(SELECTED) ' null dataset
        End With


    End Function




SO if anyone can help me figure out why this will not update the table , I would really appreciate it.

Reply With Quote
  #2 (permalink)  
Old November 6th, 2006, 11:30 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there.. do you recive any error?? or nothings happends???

HTH

Gonzalo
Reply With Quote
  #3 (permalink)  
Old November 6th, 2006, 12:03 PM
Authorized User
 
Join Date: Mar 2006
Location: , , .
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

no, no error, no exception, the code all runs , but the table does not get updated

Reply With Quote
  #4 (permalink)  
Old November 6th, 2006, 01:22 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

mm.. are you sure that you are passing the rigth employeeID.. maybe that ID is wrong and that's why you are not updating anything...

can you trace the data you are giving to the command???

HTH

Gonzalo
Reply With Quote
  #5 (permalink)  
Old November 6th, 2006, 02:50 PM
Authorized User
 
Join Date: Mar 2006
Location: , , .
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am sure that the Employee ID is correct, and all of the data is passed correctly to the procedure.

Reply With Quote
  #6 (permalink)  
Old November 24th, 2006, 03:28 PM
Authorized User
 
Join Date: Aug 2006
Location: Charlotte, NC, USA.
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anubisascends
Default

If you have added the database to the solution, then every time you attempt to debug the program, it will copy the original database to the solution in the debug folder.

Try this:

run the program in debug, update your information, then go to the debug folder in projects folder, open the database in the external application (access, sql server, oracle, etc.) This will show you if it is actually updating the information

Hope this helps.

Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.
Albert Einstein
US (German-born) physicist (1879 - 1955)
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
exception is never thrown in body of try statement annumol Pro Java 1 February 11th, 2008 06:53 AM
Exception has been thrown by the target of an invo rajasarkar ASP.NET 1.0 and 1.1 Professional 2 June 19th, 2006 03:19 AM
Autosuggest Exception thrown jellie BOOK: Professional Ajax ISBN: 978-0-471-77778-6 3 March 14th, 2006 10:19 AM
exception on update munmin2000 Visual Basic 2005 Basics 0 December 21st, 2005 06:17 AM
Exception thrown Invalid_Viewstate r_ganesh76 ASP.NET 1.0 and 1.1 Professional 1 December 2nd, 2005 04:32 PM



All times are GMT -4. The time now is 07:08 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.