YAFLogo

Posted by: Nico - Wednesday, 30 July 2008 17:38:10
Good morning everybody. Now it's 9 at Beijing, weather's cloudy after night rain, little windy (all this is good for Olympics pollution). I am currently trying to [b]add two new fields in the Post New Topic form[/b]. I work on my Code Exchange site. I want my users to add the [u]language[/u] they are going to use in the topic, and also to say if needed which [u]IDE[/u] (VB, C++, C#,.NET,...) their topic is about. Some of this works for now, some not, I'm still on it. - I have added the two new fields in database ([i]dbo.yaf_Topics[/i]). No pb [b]it works[/b] with no pb in the tool. - I have added 2 asp:DropDownList in [i]postmessage.ascx[/i] and the list elements in [i]postmessage.ascx.cs[/i] (just like 'Priority'). [b]This works[/b], the new fields appear, no pb with the general use of the tool. - The problem is now to get these fields value and to add them into the database. For this it is necessary to modify the source code of [i]YAF.Classes.Data.dll[/i] as we must act on [i]DB.cs[/i] ([i]DB.topic_save()[/i] function is called by [i]PostReplyHandleNewPost()[/i] function in [i]postmessage.ascx.cs[/i]). I have add 2 cmd.Parameters.AddWithValue() in DB.cs (also add the 2 object parameters in function inputs), and also added these input parameters in postmessage.ascx.cs. I have then build again [i]YAF.Classes.Data.dll[/i] thanks to Visual Studio 2005, and put the new .dll in my bin directories. But it currently stops here with this error message : '[b]Procedure or function yaf_topic_save has too many arguments specified[/b]' coming from [i]postmessage.ascx.cs[/i]. But I now have 14 arguments (input parameters) in my function, both in postmessage.ascx.cs and in DB.cs... I work on this. If someone has an idea or a comment, he's welcome:wink:

Posted by: Nico - Wednesday, 30 July 2008 22:31:13
I don't really understand [b]how the NewTopic data is saved[/b]:?: : In [i]postmessage.ascx.cs[/i] file, within [i]PostReplyHandleNewPost()[/i] function, it is said that [i]DB.topic_save()[/i] is supposed to do that : [color=green]// Save to Db[/color] [color=brown]long topicID = DB.topic_save(...12 input parameters...);[/color] When you go to the source code for [i]YAF.Classes.Data[/i], in the [i]DB.cs[/i] function, all the 12 input parameters are added in a SqlCommand which name is 'cmd'. All that I can see is that all these parameters are not directly linked to the [i]dbo.yaf_topics[/i] table in the data base. 'cmd' is made thanks to [i]DBAccess.GetCommand( "topic_save" )[/i]. In DBAccess.cs (always in [i]YAF.Classes.Data[/i]), GetCommand with only one input parameters returns GetCommand(storedProcedure, null), the same with 2 input parameters (the second is null)... In fact, it just creates a new StoredProcedure which name is "topic_save" and connection is null... A new DataTable called 'dt' is created thanks to DBAccess.GetData() function. This function with one parameter returns [i]DBAccess.GetData(cmd, false)[/i], the same with two parameters. This one is supposed to return [i]GetDatasetBasic( cmd, transaction ).Tables [0][/i]. [b]If somebody can explain me at which step the 12 parameters data are sent to the database and in which tables, it would be a pleasure[/b], because now I can only :cry: (don't forget that my final goal is to have 14 parameters)

Posted by: Jaben - Thursday, 31 July 2008 01:06:46
We are not talking about tables. YAF uses STORED PROCEDURES. topic_save is a stored procedure that takes 12 parameters. And yes, it works.

Posted by: Nico - Thursday, 31 July 2008 01:39:49
Thanks. I'm gonna take a closer look on the web on how these stored procedures work. Is it possible to access these procedures somewhere in the source?

Posted by: Nico - Sunday, 3 August 2008 16:16:55
Ok I got it. Didn't know there were some procedures 'hidden' into the database, just discovering .net. I have succeeded in adding my 2 new fields in the New Topic form and also modified the 'Search' tool to take them into account. I write a whole how to on it and upload it as soon as it's ready...

Posted by: Nico - Sunday, 3 August 2008 18:50:10
Not possible to upload here. Solution in: http://forum.yetanotherforum.net/yaf_postst6548_SOLUTION--add-new-fields-in-NEWTOPIC-and-use-them-in-SEARCH.aspx