|
|
 Prize winner in Competition
"VB.NET Oct 2006"
Comments and Discussions
|
|
 |

|
"System.Data.SqlClient.SqlException: Violation of PRIMARY KEY constraint 'PK_RoutinesXref'. Cannot insert duplicate key in object 'RoutinesXref'.
The statement has been terminated."
I kept running into this error when I was trying to document a quite large database. I solved the issue by modifying the DBDoc database:
Simply add a column to the table "RoutinesXref", with these properties:
Column name: PK (or whatever)
Data Type: int
Length: 4
Identity: Yes
Identity Seed: 1
Identity Increment: 1
After creating it, select the newly created column, "ObjectID" and "CalledObjectID".
Set them as the primary key for the table.
Problem solved.
"Learning without thought is labor lost; thought without learning is perilous."
-- Confucius
|
|
|
|

|
Eager to see version which includes views. Keep up the good work ! Got my 5
~ prabal
|
|
|
|

|
This has now been added to my essential development tools list.
Truly Marvelous,
Thank you.
|
|
|
|

|
This your comment push me to think about enhancements and SQL2005 version.
Thank you!
AV
|
|
|
|

|
Yes, Yes, Yes please, SQL2005 support would be great.
PS I added this bit to make the Search Tab and Favourites Tab appear,
and Buttons for Locate , Back and Forward
- in GenerateHHPfile
w.WriteLine("TOC=,""toc.hhc"",""index.hhk"",""welcome.htm"",""welcome.htm"",,,,,0x61520,,0x187c,[100,100,600,600],0x30000,,,,,,0")
Thanks Again
|
|
|
|

|
Hi
I downloaded and tried DBDoc the other day, and I am very impressed! We are definitely going to use it for documenting our databases.
The only missing aspect for us is support for views, although from my limited understanding of the system object tables in SQL Server, this shouldn't be to hard to add. So, just wondering, was there any reason you didn't include Views as standard i.e. is there some hidden complexity that I need to look out for, or did you just not have the time or something?
Anyway, thanks again for such a great tool - much appreciated!
Cheers
Brett
|
|
|
|

|
Simply: DBdoc arose as a tool for my own use, and initially I hadn't to document database Views. Along with the lack of time, this is the only reason I didn't implement support for Views.
I understand your doubt about "hidden complexity" of Views. But it's quite easy to implement DBdoc support for them: for example, syntax parsing is very easy (they have no parameters). I think I'll implement that support soon. Let's see who of us will do it first!
AV
|
|
|
|

|
We are using DBdoc to document a SQL-2000 DB in our company. There seems to be a little bug regarding the signature of a stored procedure/function that is stored in column "Syntax" in table "Routines". If the name of the sp/function is enclosed in square brackets the signature is not created. It is only displayed as "procedure" or "function" without any following content. Without the square brackets DBDoc generates the signature correctly.
The SQL Management Studio for SQL-Server 2005 we use to manage our SQL Server 2000 DB encloses the names of sp/functions in square brackets. So the documentation generated by DBDoc is incomplete.
Is there a way to fix this? Is it possible to generate the signature for sp/functions with names enclosed in []?
Kind regards.
Stephan
|
|
|
|

|
DBdoc currently implements syntax recognition through some Spart parsers. As you can see in files TSQL_CreateSP.vb and TQSL_CreateFN.vb, the parsers for procedures and functions names are respectively defined in this way:
proc_name.Parser = Comp.Seq(Prims.Letter, Comp.Star(Comp.Alt(Prims.LetterOrDigit, "_", ".")))
proc_namedel.Parser = Comp.Seq("""", Prims.Letter, Comp.Star(Comp.Alt(Prims.LetterOrDigit, "_", " ")), """")
func_name.Parser = Comp.Seq(Prims.Letter, Comp.Star(Comp.Alt(Prims.LetterOrDigit, "_", ".")))
func_namedel.Parser = Comp.Seq("""", Prims.Letter, Comp.Star(Comp.Alt(Prims.LetterOrDigit, "_", " ")), """")
So, currently, some names are recognized as "delimited names" only if they start/end with the double-quote character (").
No support for "[]" is implemented at the moment, but it is not difficult to modify the parsers in order to add this pattern recognition: you could to it by yourself.
If you're not interested in "double-quoted identifiers", a first step could be converting:
proc_namedel.Parser = Comp.Seq("""", Prims.Letter, Comp.Star(Comp.Alt(Prims.LetterOrDigit, "_", " ")), """")
func_namedel.Parser = Comp.Seq("""", Prims.Letter, Comp.Star(Comp.Alt(Prims.LetterOrDigit, "_", " ")), """")
in:
proc_namedel.Parser = Comp.Seq("[", Prims.Letter, Comp.Star(Comp.Alt(Prims.LetterOrDigit, "_", " ")), "]")
func_namedel.Parser = Comp.Seq("[", Prims.Letter, Comp.Star(Comp.Alt(Prims.LetterOrDigit, "_", " ")), "]")
AV
|
|
|
|

|
Ciao Alberto I'm testing your tool and I tried to put some html code inside an XML node because I wanted to list the possible values for a store proc parameter. The html code is very simply (here is an example): <PARAM_IN name="@objType"> String representing the type of the object to check on. It can be: <ul> <li> T or U for table </li> <li> V for view</li> <li> P or SP for stored procedure</li> <li> F, UDF, FN, IF or TF for user defined function</li> </ul> If null checks if the object exists regardless of its type. </PARAM_IN> DBDoc generated the output but the related html misses the <ul> and <li> tags. Debugging with VS2003 I realized that these info are lost during XSL transformation using the P_template.xslt file. In fact the XMLDoc in the GenerateHTMLtopicFileR method contains the string with the html tags. I have to say that I don't know XSL so my question is if there's a reasonable quick way to generate text inside a xml tag "as is". I mean something that acts like "verbatim" in LaTex. Thank you for your attention. Ciao Marcello
|
|
|
|

|
Ciao Marcello. Let me say that you did a very good investigation and debugging: you detected the exact area where the issue arises. What a shame for your XSLT knowledge gap! But I'm sure you'll fill it soon. The problem is that your <ul> and <li> nodes are interpreted as a part of the well-formed XML you're supplying in the <DOC> section. So, they're considered as sub-nodes of <PARAM_IN> node. The first thing is to instruct your XML that your HTML snippet is (as a whole) the inner text of the <PARAM_IN> node. To do so, just make it a CDATA section: <PARAM_IN name="@objType"> <![CDATA[ String representing... ...of its type. ]]> </PARAM_IN> If you re-run DBdoc after this modification, you will see your tags re-appear in the final HTML documentation, with a new issue: you actually see them as "<ul>" and "<li>". This happens because, by default, when transforming a CDATA section, XSLT engine produces an output that will show our CDATA exactly "as is"; so, by default, XSLT will "escape" some characters like "<" and ">", in order to make them appear in the final output (look at the HTML source...). Of course, you don't want this: you want to have "<ul>" and "<li>" functioning as effective HTML tags, being interpreted by the CHM Help Viewer. What you need is now a simple modification to the P_template.xslt file. Just substitute: <xsl:for-each select="PARAM_IN"> <dt><i><xsl:value-of select="./@name"/></i></dt> <dd><xsl:value-of select="."/></dd> </xsl:for-each> with: <xsl:for-each select="PARAM_IN"> <dt><i><xsl:value-of select="./@name"/></i></dt> <dd><xsl:value-of select="." disable-output-escaping="yes"/></dd> </xsl:for-each> With the "disable-output-escaping" directive, the text node generated by instantiating the xsl:value-of will be put in the output without any escaping, and you'll get the result you're looking for. For sure, if you use HTML snippets extensively in other documentation comments, you'll need to add other disable-output-escaping="yes" attributes in the proper position of the interested XSLT transformations. Hope this will be helpful to you. Regards, AV
|
|
|
|

|
Ciao Alberto Thanks a lot, your solution works fine!! Personally I don't like the CDATA tag syntax inside the XML comment, so I tried using "<HTML>" and "</HTML>" tags and replacing them with "<![CDATA[" and the "]]>" respectively in the ExtractXMLcomment function just before the return statement. It works fine although it's not very elegant. I will modify all the XSL templates to suit my needs. I noticed the ExcludedTables and ExcludedRoutines SQL Server tables but at the moment they are not populated. What about your original idea around these tables? I'm interested because I have some "working" tables and stored procs that I don't want to put in the final document. I thought to add something like this <DOC> ... <EXCLUDE>yes</EXCLUDE> (or <EXCLUDE>true</EXCLUDE>) ... </DOC> and adding the relative row in the proper "Excluded" table. I'm working on this now. The last question is about the Views documentation. Could you give me please any advice on implementing that? Thank you very much Alberto Ciao e buon lavoro. MF
|
|
|
|

|
As you noticed, ExcludedTables and ExcludedRoutines tables are designed to simply list the tables and routines (SP, trigger, UDF) you want to exclude from the final documentation. They actually function to this goal (I mean: the engine producing the HTML help project files takes into account their content in order to avoid producing output about those listed objects).
But, and you're right, a the moment there is no way or GUI to populate ExcludedTables and ExcludedRoutines tables (I did it manually when needed, of course in a DBToBeDoc by DBToBeDoc basis).
Your idea to enrich the commenting syntax with such a "flag" excluding an object from documentation is quite good; please, let us know your results in this effort.
About commenting/documenting VIEWS, the processing path is quite similar to other objects. So, you need to define an XML commenting structure (easy, because of lacks of parameters); you need to collect raw metadata from the ToBeDoc DB (probably in sysobjects and syscomments system tables); you need to extract the XML comment snippet from the VIEW source code; you need to transform it through a custom XSLT. I think you have all the building block samples in what is already implemented. IT should be not so difficult to extend DBdoc.
Good luck, AV
|
|
|
|
|

|
This is a fantastic article for DB documenatation. I tried using this for SQL Server 2000 DB and it works fine.
If I need to use this DB doc tool for SQL Server 2005 database, will it help?????
|
|
|
|

|
As you know, the new version 2005 of Microsoft SQL Server offers lots of enhancements on the previous one, many of them regarding the T-SQL syntax itself (just to make and example, think about the new syntax for attaching managed code in UDF, trigger, stored procedures...).
Also, many modifications occurred on the internal metadata storage (to which DBdoc accesses directly, with low hopes of forward compatibility on versions after 2000).
These reasons made me think about "DBdoc for SQL2005" as a tool that needs lot of revision and re-writing; so the support for SQL2005 is just in my mind, relegated to the moment when I'll have enough time to spend on it.
The challenge is anyway open: the source code of "DBdoc for SQL2000" is there...
AV
-- modified at 5:49 Thursday 16th November, 2006
|
|
|
|

|
Let me know when you are going to come up with SQLServer 2005 Version as i am facing a problem with generating a documentation for SQL Server 2005. I am enclosing the error i am encountering while running against SQLServer 2005. System.Data.SqlClient.SqlException was unhandled Class=16 ErrorCode=-2146232060 LineNumber=1 Message="Invalid object name 'master.dbo.spt_datatype_info'." Number=208 Procedure="" Server="(local)" Source=".Net SqlClient Data Provider" State=1 StackTrace: at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlDataReader.ConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) at DBdoc.frmMain.ReadRawMetadata() in C:\DBdoc\DBdoc\frmMain.vb:line 682 at DBdoc.frmMain.cmdAnalyse_Click(Object sender, EventArgs e) in C:\DBdoc\DBdoc\frmMain.vb:line 630 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at DBdoc.frmMain.Main() in C:\DBdoc\DBdoc\frmMain.vb:line 7 at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() The above error is generated while Analysing (Analyze button click) and when it tries to execute the following sql script. SQLstr = "SELECT" SQLstr &= " OBJECTID = o.id," SQLstr &= " SPECIFIC_CATALOG = db_name()," SQLstr &= " SPECIFIC_SCHEMA = user_name(o.uid)," SQLstr &= " SPECIFIC_NAME = o.name," SQLstr &= " ROUTINE_TYPE = convert(nvarchar(20), o.xtype)," SQLstr &= " CHARACTER_MAXIMUM_LENGTH = convert(int, OdbcPrec(c.xtype, c.length, c.xprec) + spt_dtp.charbin)," SQLstr &= " NUMERIC_PRECISION = c.xprec," SQLstr &= " NUMERIC_PRECISION_RADIX = spt_dtp.RADIX," SQLstr &= " NUMERIC_SCALE = c.scale," SQLstr &= " DATETIME_PRECISION = spt_dtp.SQL_DATETIME_SUB," SQLstr &= " CREATED = o.crdate," SQLstr &= " LAST_ALTERED = o.crdate" SQLstr &= " FROM sysobjects o" SQLstr &= " LEFT OUTER JOIN (syscolumns c" SQLstr &= " JOIN master.dbo.spt_datatype_info spt_dtp" SQLstr &= " ON c.xtype = spt_dtp.ss_dtype" SQLstr &= " AND (spt_dtp.ODBCVer is null or spt_dtp.ODBCVer = 2)" SQLstr &= " AND (spt_dtp.AUTO_INCREMENT is null or spt_dtp.AUTO_INCREMENT = 0))" SQLstr &= " ON (o.id = c.id AND c.number = 0 AND c.colid = 0)," SQLstr &= " master.dbo.syscharsets a_cha /* charset/1001, not sortorder */" SQLstr &= " WHERE o.xtype IN ('P','FN','TF','IF','TR')" 'SQLstr &= " AND permissions(o.id) != 0" SQLstr &= " AND o.category <> 2 /* AV: exclude system objects */" SQLstr &= " AND a_cha.id = isnull(convert(tinyint, CollationProperty(c.collation, 'sqlcharset'))," SQLstr &= " convert(tinyint, ServerProperty('sqlcharset')))" cmd.CommandText = SQLstr da.Fill(ds, "RawRoutines1") Some problem with the existence of the table. MEANTIME I AM GOING AHEAD WITH TYRING TO GET IT WORKING FOR SQL2005. Regards Ram parshu1@vsnl.com Parshuram
|
|
|
|

|
Ram, I had no doubt it couldn't work on SQL2005, as I said about deep system metadata changes in the new SQL version!!!
AV
|
|
|
|

|
i could make it working for SQL2005 as we had some important delivery coming up for our project. I had to copy the structure and the data from SQL2000 db to SQL2005 which are spt_datatype_info , syscharsets tables. some more points that i am working are 1. Asking for Schema Name input along with other db connection parameters. 2. Generating Documentation for Views 3. Generating Description for Table. Currently there was no other choice but to pick up the existing tables from sql2000. But as a long term solution, i would be making it fully compatible with SQL2005 wherein it just works without those above tables. Thanks for all the good inputs that you have given us to start off with. Let me know if i can work on something else with you. I am working as a Technical Lead with a Strategic Management consultancy for its InHouse IT Department. Currently using dotnet1.1, 2.0 and sql2005 for our developments.
Regards Ram parshu1@vsnl.com
Ram
|
|
|
|

|
Hi,
The efforts you have put to make the Dbdoc system is excellent and it is very helpful.
I have started using your Dbdoc system just two months back, and it is working absolutely fine.
But NOW the Problem is our databases are shifted to SQL 2005. Now I find it very much Tough, Everywhere it is throwing Exceptions and nothing is happening correct.
Can you please tell us , when you are planning for SQL 2005.
We all will be very much thankful if u come up with SQL 2005.
Good Work Done, I appreciate !!!!
Thanks,
Sidheshwar.
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
|
A tool to generate CHM documentation files for SQL Server 2000 databases
| Type | Article |
| Licence | |
| First Posted | 14 Nov 2006 |
| Views | 97,945 |
| Bookmarked | 160 times |
|
|