Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 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 April 30th, 2009, 10:50 PM
Registered User
 
Join Date: Apr 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using Mysql for forum & stored proc. problems

I am trying to use the beer house design, but modify it for use with Mysql. I am working now on the forums, and have run into some issues. One is the stored procedures, I don't seem to be able to get stored procedures to work if the command type is commandtype.storedprocedure, but it does work if I use commandtype.text. What am I missing here-or do I just need to use commandtype.text?

My next problem is that the GetThreads routine returns zero rows, can anybody tell what I am doing wrong here? I get through the first GetThreads on loading of the Forums ok, but then when I select a forum it gives me an error stating zero rows were returned. I trimmed the tbh_ off the table names, and modified the routine as follows:

Code:
Dim sql AsString = String.Format("SELECT " & _
"posts.PostID, posts.AddedDate, posts.AddedBy, posts.AddedByIP, " & _
"posts.ForumID, posts.ParentPostID, posts.Title, posts.Approved, " & _
"posts.Closed, posts.ViewCount, posts.ReplyCount, posts.LastPostDate, " & _
"posts.LastPostBy " & _
"FROM posts " & _
"INNER JOIN forums " & _
"ON posts.forumid=Forums.forumid " & _
"WHERE ParentPostID = 0 AND Approved = 1 AND posts.forumID = {1} " & _
"ORDER BY {0} " & _
"LIMIT {2},{3};", _
sortExpression, forumID, lowerBound, upperBound)

Like I said, I use basically the same routine in the inital forum loading that appears to work (does'nt give an error) but it does'nt work for me when selecting the forum. Does anybody have an example or experience in what all needs to be changed to use Mysql for the whole site?
 
Old May 1st, 2009, 01:39 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Since you are using text here, CommandType.StoredProcedure won't work, so that's the answer to your first issue.

I believe the second issue could be related to the fact that but you seem to be mIxInG CaSeS all over the place. For example:

"INNER JOIN forums " & _
"ON posts.forumid=Forums.forumid " &

You need to be more careful on how you are constructing the string in terms of casing.
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old May 3rd, 2009, 02:21 PM
Registered User
 
Join Date: Apr 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the help. I don't understand why I can't use stored procedure here. The only change I made was to add the "CALL" to the command.

Code:
PublicOverridesFunction GetForums() As List(Of ForumDetails)
Using cn AsNew MySqlConnection(Connection)
Dim cmd AsNew MySqlCommand("CALL tbh_Forums_GetForums()", cn)
cmd.CommandType = CommandType.StoredProcedure
cn.Open()
Return GetForumCollectionFromReader(ExecuteReader(cmd))
EndUsing
EndFunction
When I use this, I get the "There is no row at position 0" error. If I use commandtype.text it works. What do I need to do to call a stored procedure in mysql the right way.

I will work on the table naming issue, thanks. Column names are not case sensitive but table names are, I forgot about that.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling an insert stored proc from a select stored dzitam SQL Language 10 April 2nd, 2007 12:39 PM
How to get value from stored proc busybee ASP.NET 1.0 and 1.1 Basics 4 April 2nd, 2006 01:06 AM
Location of Stored Procedure & Function in MySQL kasie MySQL 8 March 22nd, 2005 10:54 AM
Linux & KDE & C++ & QT & MYSQL & Kdevelop Munnnki Linux 0 January 2nd, 2005 05:41 PM
problems with stored proc and output parameters zieg42 VB.NET 2002/2003 Basics 1 June 12th, 2004 07:11 AM





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