Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 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
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 11th, 2007, 01:31 PM
Authorized User
Join Date: Jul 2007
Location: , , .
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Code running without any result

I am running Access form to pass parameters to a stored procedure in sql server backend in the pubs database to update records. However, the code is working but the results are not. This means for some reason the code is not updating the data. I believe, it has to do with data type issues. I am not certain though. I would appreciate if someone can help me to figure out why the stored procedure is not running. Thanks
Private Sub cmdRunProc1_Click()

Dim conn As ADODB.Connection
'Dim cmdUpdate As ADODB.Command
Dim lngRecs
Dim strType
Dim curPercent

Set conn = New ADODB.Connection

conn.Provider = "SQLOLEDB"

conn.ConnectionString = "Provider=SQLOLEDB.1;Initial Catalog=pubs;Data Source=USILDEK1-21001;User ID=sa;Password=alloyd;"

Set cmdUpdate = New ADODB.Command
cmdUpdate.CommandType = adCmdStoredProc
cmdUpdate.CommandText = "usp_UpdatePrices"
Set cmdUpdate.ActiveConnection = conn

' Get the form values
strType = Forms!frmParamPassing_mod!txtBookType
curPercent = Forms!frmParamPassing_mod!txtPercent
curPercent1 = CCur(Forms!frmParamPassing_mod!txtPercent)

    ' Add the parameters
    cmdUpdate.Parameters.Append cmdUpdate.CreateParameter("@Type", adVarWChar, adParamInput, 12, strType)
    cmdUpdate.Parameters.Append cmdUpdate.CreateParameter("@Percent", adCurrency, adParamInput, , curPercent1)

' Execute the command
    cmdUpdate.Execute lngRecs, , adExecuteNoRecords

' And finally tell the user what's happened

MsgBox ("Procedure complete. Records were updated")

Set conn = Nothing
Set cmdUpdate = Nothing
End Sub


create procedure usp_updateprices

@type char(12),
@percent money
update titles
set price = price * ( 1 + @percent /100)
where type = @type
Reply With Quote
  #2 (permalink)  
Old July 11th, 2007, 02:29 PM
Imar's Avatar
Wrox Author
Points: 72,022, Level: 100
Points: 72,022, Level: 100 Points: 72,022, Level: 100 Points: 72,022, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,076
Thanks: 80
Thanked 1,587 Times in 1,563 Posts

Hi jack123,

It could indeed be a data type issue. Your procedure expects a char(12). The char data type is padded with spaces by default. If the underlying value you're querying is of a different type, you may have a mismatch. That is, "SomeValue " is not the same as "SomeValue".

Hope this helps,


Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #3 (permalink)  
Old July 11th, 2007, 05:02 PM
Authorized User
Join Date: Jul 2007
Location: , , .
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts

This work now. I do not know why it was not working before. Anyway,
Thanks for viewing.
Reply With Quote

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
Running the source code Sheraz Khan ASP.NET 2.0 Professional 1 September 11th, 2007 01:47 AM
Please help my code is not giving me a result set yudee JSP Basics 0 September 20th, 2006 09:55 AM
Code not running larryg BOOK: Beginning Access VBA 3 August 18th, 2006 08:36 AM
Send code to server and getto=ing back result topshed Classic ASP Professional 1 January 30th, 2006 12:56 AM

All times are GMT -4. The time now is 09:14 AM.

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