|
Comments and Discussions
|
|
 |
 |
Back in 2012 you were working on a new program. Was wondering how that is coming?
|
|
|
|
|
 |
Excellent! This is just what I have long sought for. Unfortunately,I can't download the sourcecode. Could you send me an email? My email:[email protected].
Thank you very much!
|
|
|
|
|
 |
Please tell me...
i can/t find AddSqlParm method and getting error.
please tell me where is it...
|
|
|
|
|
 |
Still looking for the missing AddSqlParm method. Can you point to that. The link posted does not work.
|
|
|
|
 |
In the Comments and Discussions section of this article on the 1 Sep '08 at 12:02 I posted the following.
Note the methods are from the AdventureWorks database, so you have to change the class name.
hope it helps
public static class AdventureWorks
{
public static SqlParameter AddSqlParm(string ParmName, object Value, SqlDbType Sqltype)
{
return AddSqlParm(ParmName, Value, Sqltype, -1);
}
public static SqlParameter AddSqlParm(string ParmName, object Value, SqlDbType Sqltype, int SqlSize)
{
SqlParameter genSqlData;
if ((SqlSize == -1))
genSqlData = new SqlParameter(ParmName, Sqltype);
else
genSqlData = new SqlParameter(ParmName, Sqltype, SqlSize);
if ((Value == null))
genSqlData.Value = DBNull.Value;
else
genSqlData.Value = Value;
return genSqlData;
}
}
With great code, comes great complexity, so keep it simple stupid...
|
|
|
|
 |
Hi,
First of all, Thanks for the wonderful code generator tool.
I'm planning to update this Software and put this in my blog or somewhere else in the internet, of course getting approval from the Creator Paw Jershauge .
I've already fixed few bugs. We are using this tool in our projects also..
Please send the bugs or feature needed to my Email ID :
[email protected]
I can also ready to move this to Google Code / CodePlex / SourgeForge..so we can actively do update, maintain Todo list and maintain bugs using tracker.
Thanks,
Thiyagu
|
|
|
|
 |
Hello Thiyagu, if Paw Jershauge accept your proposal that can be a solution to improve a program that is really good. I'd like to take part by contributing ideas, but my level in this programming language is low.
ipadilla
|
|
|
|
|
 |
No problem at all on my part. Thank you.
ipadilla
|
|
|
|
 |
Hi,
I'd be prepared to contribute to this project.
Have you established it at CodePlex or elsewhere yet?
Dave Cross
|
|
|
|
|
 |
Oh, that presents me with a problem!
Do I invest time and effort into understanding this version and then modifying it to suit my own needs or wait until your new super project sees the light of day?
My colleagues and I were just about to write our own class generator when I found this article and it does seem such a waste of time to re-invent the wheel.
What do you advise?
Dave Cross
|
|
|
|
 |
 Hey Dave
I would be happy to present you the newer version, over email. BUT the project is not totaly done.
Still I would recomment you to get the new version og the project since its SQL Server version independent,
my new project handles all versions of the SQL Server from 2000 (version 8) to 2012 (version 11 "Denali")
let me know what you want to do
Alternative I could send you alle the base Classes so you will not have to write them again.
Heres an exsample of the base class for Table on Sql server version 110
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Text;
using System.ComponentModel;
using PawJershauge.SqlMetaData.Shared;
namespace PawJershauge.SqlMetaData.Shared.BaseClasses
{
#region Code & Copyright notification
/*
Copyright © 2008 - 2011, Paw Jershauge
All rights reserved.
http://pawjershauge.blogspot.com or http://Paw.jershauge.dk
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Neither the name Paw Jershauge, nor the names of this project may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
################################################################################################
Documentation text:
------------------------------------------------------------------------------------------------
All text added to members of this class is based on information from MSDN and therefor the text Copyright belongs to Microsoft.
GENERATOR:
------------------------------------------------------------------------------------------------
The Code was generated with: Code Architect Studio 2011 by Paw Jershauge
CODE:
------------------------------------------------------------------------------------------------
The Code and Documentation is based on information from the following url.
url: http://msdn.microsoft.com/en-us/library/ms187406(SQL.110).aspx
MSDN:
------------------------------------------------------------------------------------------------
- http://msdn.microsoft.com/en-us/library/ms187406(SQL.110).aspx
- http://msdn.microsoft.com/en-us/library/ms190324(v=SQL.110).aspx
ABOUT:
------------------------------------------------------------------------------------------------
Name: Paw Jershauge
Email: [email protected]
Blog: (C# and I): http://pawjershauge.blogspot.com
Class Generation Date: 16-09-2011 11:19:42
*/
#endregion
///<summary>
/// Returns a row for each table object, currently only with sys.objects.type = U.
///</summary>
[Description(@"Returns a row for each table object, currently only with sys.objects.type = U.")]
[EditorBrowsableAttribute()]
public class SqlMetaDataTable_110 : SqlMetaDataObject_110, ISqlMetaDataTable
{
#region const
/// <summary>
/// Primary Transact-SQL select statement
/// </summary>
public new const string SqlSelectAll = "SELECT [name], [object_id], [principal_id], [schema_id], [parent_object_id], [type], [type_desc], [create_date], [modify_date], [is_ms_shipped], [is_published], [is_schema_published], [lob_data_space_id], [filestream_data_space_id], [max_column_id_used], [lock_on_bulk_load], [uses_ansi_nulls], [is_replicated], [has_replication_filter], [is_merge_published], [is_sync_tran_subscribed], [has_unchecked_assembly_data], [text_in_row_limit], [large_value_types_out_of_row], [is_tracked_by_cdc], [lock_escalation], [lock_escalation_desc], [is_filetable] FROM sys.tables";
public new const string SqlJoinedDBSelectAll = "CREATE TABLE #JT (CASDBNAME sysname,name sysname NULL, object_id int NULL, principal_id int NULL, schema_id int NULL, parent_object_id int NULL, type char(2) NULL, type_desc nvarchar(60) NULL, create_date datetime NULL, modify_date datetime NULL, is_ms_shipped bit NULL, is_published bit NULL, is_schema_published bit NULL, lob_data_space_id int NULL, filestream_data_space_id int NULL, max_column_id_used int NULL, lock_on_bulk_load bit NULL, uses_ansi_nulls bit NULL, is_replicated bit NULL, has_replication_filter bit NULL, is_merge_published bit NULL, is_sync_tran_subscribed bit NULL, has_unchecked_assembly_data bit NULL, text_in_row_limit int NULL, large_value_types_out_of_row bit NULL, is_tracked_by_cdc bit NULL, lock_escalation tinyint NULL, lock_escalation_desc nvarchar(60) NULL, is_filetable bit NULL)\nINSERT INTO #JT\nEXEC sp_MSForEachDB 'SELECT ''?'' as [CASDBNAME],[name], [object_id], [principal_id], [schema_id], [parent_object_id], [type], [type_desc], [create_date], [modify_date], [is_ms_shipped], [is_published], [is_schema_published], [lob_data_space_id], [filestream_data_space_id], [max_column_id_used], [lock_on_bulk_load], [uses_ansi_nulls], [is_replicated], [has_replication_filter], [is_merge_published], [is_sync_tran_subscribed], [has_unchecked_assembly_data], [text_in_row_limit], [large_value_types_out_of_row], [is_tracked_by_cdc], [lock_escalation], [lock_escalation_desc], [is_filetable] FROM [?].sys.tables'\nSELECT * FROM #JT\nDROP TABLE #JT";
#endregion
#region fields
private SqlMetaDataSchema_110 _Schema = null;
//Inherited from SqlMetaDataObject private System.String _name;
//Inherited from SqlMetaDataObject private System.Int32? _object_id;
//Inherited from SqlMetaDataObject private System.Int32? _principal_id;
//Inherited from SqlMetaDataObject private System.Int32? _schema_id;
//Inherited from SqlMetaDataObject private System.Int32? _parent_object_id;
//Inherited from SqlMetaDataObject private System.String _type;
//Inherited from SqlMetaDataObject private System.String _type_desc;
//Inherited from SqlMetaDataObject private System.DateTime? _create_date;
//Inherited from SqlMetaDataObject private System.DateTime? _modify_date;
//Inherited from SqlMetaDataObject private System.Boolean? _is_ms_shipped;
//Inherited from SqlMetaDataObject private System.Boolean? _is_published;
//Inherited from SqlMetaDataObject private System.Boolean? _is_schema_published;
private System.Int32? _lob_data_space_id = null;
private System.Int32? _filestream_data_space_id = null;
private System.Int32? _max_column_id_used = null;
private System.Boolean? _lock_on_bulk_load = null;
private System.Boolean? _uses_ansi_nulls = null;
private System.Boolean? _is_replicated = null;
private System.Boolean? _has_replication_filter = null;
private System.Boolean? _is_merge_published = null;
private System.Boolean? _is_sync_tran_subscribed = null;
private System.Boolean? _has_unchecked_assembly_data = null;
private System.Int32? _text_in_row_limit = null;
private System.Boolean? _large_value_types_out_of_row = null;
private System.Boolean? _is_tracked_by_cdc = null;
private System.Byte? _lock_escalation = null;
private System.String _lock_escalation_desc = null;
private System.Boolean? _is_filetable = null;
#endregion
#region properties
///<summary>
/// Sql Object Type.
///</summary>
[Category(@"Meta Data Properties")]
[Description(@"Sql Object Type.")]
public override SqlMetaDataObjectType SqlObjectType
{
get { return SqlMetaDataObjectType.SqlMetaDataTable; }
}
///<summary>
/// Sql Version.
///</summary>
[Category(@"Meta Data Properties")]
[Description(@"Sql Version.")]
public override SqlVersion SqlVersion
{
get { return SqlVersion.Sql_Denali; }
}
///<summary>
/// Returns false. (No Sub version of this class, this class is base class).
///</summary>
[Category(@"Meta Data Properties")]
[Description(@"Returns false. (No Sub version of this class, this class is base class).")]
public System.Boolean SqlObjectDiffers
{
get { return false; }
}
//Inherited from SqlMetaDataObject.Name
//Inherited from SqlMetaDataObject.ObjectId
//Inherited from SqlMetaDataObject.PrincipalId
//Inherited from SqlMetaDataObject.SchemaId
//Inherited from SqlMetaDataObject.ParentObjectId
//Inherited from SqlMetaDataObject.Type
//Inherited from SqlMetaDataObject.TypeDesc
//Inherited from SqlMetaDataObject.CreateDate
//Inherited from SqlMetaDataObject.ModifyDate
//Inherited from SqlMetaDataObject.IsMsShipped
//Inherited from SqlMetaDataObject.IsPublished
//Inherited from SqlMetaDataObject.IsSchemaPublished
///<summary>
/// A nonzero value is the ID of the data space (filegroup or partition scheme) that holds the text, ntext, and image data for this table.
/// 0 = The table does not contain text, ntext, or image data.
///</summary>
[Description(@"A nonzero value is the ID of the data space (filegroup or partition scheme) that holds the text, ntext, and image data for this table., 0 = The table does not contain text, ntext, or image data.")]
public System.Int32? LobDataSpaceId
{
get { return _lob_data_space_id; }
}
///<summary>
/// Is the data space ID for a FILESTREAM filegroup or a partition scheme that consists of FILESTREAM filegroups.
/// To report the name of a FILESTREAM filegroup, execute the query SELECT FILEGROUP_NAME (filestream_data_space_id) FROM sys.tables.
/// sys.tables can be joined to the following views on filestream_data_space_id = data_space_id.
/// sys.filegroups
/// sys.partition_schemes
/// sys.indexes
/// sys.allocation_units
/// sys.fulltext_catalogs
/// sys.data_spaces
/// sys.destination_data_spaces
/// sys.master_files
/// sys.database_files
/// backupfilegroup (join on filegroup_id)
///</summary>
[Description(@"Is the data space ID for a FILESTREAM filegroup or a partition scheme that consists of FILESTREAM filegroups. , To report the name of a FILESTREAM filegroup, execute the query SELECT FILEGROUP_NAME (filestream_data_space_id) FROM sys.tables., sys.tables can be joined to the following views on filestream_data_space_id = data_space_id., sys.filegroups, sys.partition_schemes, sys.indexes, sys.allocation_units, sys.fulltext_catalogs, sys.data_spaces, sys.destination_data_spaces, sys.master_files, sys.database_files, backupfilegroup (join on filegroup_id)")]
public System.Int32? FilestreamDataSpaceId
{
get { return _filestream_data_space_id; }
}
///<summary>
/// Maximum column ID ever used by this table.
///</summary>
[Description(@"Maximum column ID ever used by this table.")]
public System.Int32? MaxColumnIdUsed
{
get { return _max_column_id_used; }
}
///<summary>
/// Table is locked on bulk load. For more information, see sp_tableoption (Transact-SQL)2.
///</summary>
[Description(@"Table is locked on bulk load. For more information, see sp_tableoption (Transact-SQL)2.")]
public System.Boolean? LockOnBulkLoad
{
get { return _lock_on_bulk_load; }
}
///<summary>
/// Table was created with the SET ANSI_NULLS database option ON.
///</summary>
[Description(@"Table was created with the SET ANSI_NULLS database option ON.")]
public System.Boolean? UsesAnsiNulls
{
get { return _uses_ansi_nulls; }
}
///<summary>
/// 1 = Table is published using snapshot replication or transactional replication.
///</summary>
[Description(@"1 = Table is published using snapshot replication or transactional replication.")]
public System.Boolean? IsReplicated
{
get { return _is_replicated; }
}
///<summary>
/// 1 = Table has a replication filter.
///</summary>
[Description(@"1 = Table has a replication filter.")]
public System.Boolean? HasReplicationFilter
{
get { return _has_replication_filter; }
}
///<summary>
/// 1 = Table is published using merge replication.
///</summary>
[Description(@"1 = Table is published using merge replication.")]
public System.Boolean? IsMergePublished
{
get { return _is_merge_published; }
}
///<summary>
/// 1 = Table is subscribed using an immediate updating subscription.
///</summary>
[Description(@"1 = Table is subscribed using an immediate updating subscription.")]
public System.Boolean? IsSyncTranSubscribed
{
get { return _is_sync_tran_subscribed; }
}
///<summary>
/// 1 = Table contains persisted data that depends on an assembly whose definition changed during the last ALTER ASSEMBLY. Will be reset to 0 after the next successful DBCC CHECKDB or DBCC CHECKTABLE.
///</summary>
[Description(@"1 = Table contains persisted data that depends on an assembly whose definition changed during the last ALTER ASSEMBLY. Will be reset to 0 after the next successful DBCC CHECKDB or DBCC CHECKTABLE.")]
public System.Boolean? HasUncheckedAssemblyData
{
get { return _has_unchecked_assembly_data; }
}
///<summary>
/// The maximum bytes allowed for text in row.
/// 0 = Text in row option is not set. For more information, see sp_tableoption (Transact-SQL)2.
///</summary>
[Description(@"The maximum bytes allowed for text in row., 0 = Text in row option is not set. For more information, see sp_tableoption (Transact-SQL)2.")]
public System.Int32? TextInRowLimit
{
get { return _text_in_row_limit; }
}
///<summary>
/// 1 = Large value types are stored out-of-row. For more information, see sp_tableoption (Transact-SQL)2.
///</summary>
[Description(@"1 = Large value types are stored out-of-row. For more information, see sp_tableoption (Transact-SQL)2.")]
public System.Boolean? LargeValueTypesOutOfRow
{
get { return _large_value_types_out_of_row; }
}
///<summary>
/// 1 = Table is enabled for change data capture. For more information, see sys.sp_cdc_enable_table (Transact-SQL)3.
///</summary>
[Description(@"1 = Table is enabled for change data capture. For more information, see sys.sp_cdc_enable_table (Transact-SQL)3.")]
public System.Boolean? IsTrackedByCdc
{
get { return _is_tracked_by_cdc; }
}
///<summary>
/// The value of the LOCK_ESCALATION option for the table:
/// 0 = TABLE
/// 1 = DISABLE
/// 2 = AUTO
///</summary>
[Description(@"The value of the LOCK_ESCALATION option for the table:, 0 = TABLE, 1 = DISABLE, 2 = AUTO")]
public System.Byte? LockEscalation
{
get { return _lock_escalation; }
}
///<summary>
/// A text description of the lock_escalation option for the table. Possible values are: TABLE, AUTO, and DISABLE.
///</summary>
[Description(@"A text description of the lock_escalation option for the table. Possible values are: TABLE, AUTO, and DISABLE.")]
public System.String LockEscalationDesc
{
get { return _lock_escalation_desc; }
}
///<summary>
/// 1 = this table is a FileTable.
///</summary>
[Description(@"1 = this table is a FileTable.")]
public System.Boolean? IsFiletable
{
get { return _is_filetable; }
}
#endregion
#region constructors
internal SqlMetaDataTable_110(SqlDataReader rs)
: base(rs)
{
AddFromRecordSet(rs);
}
#endregion
#region methods
private void AddFromRecordSet(SqlDataReader rs)
{
try
{
// Inherited if (!rs.IsDBNull(rs.GetOrdinal("name"))) { _name = rs.GetString(rs.GetOrdinal("name")); } // Original SQL DataType: sysname
// Inherited if (!rs.IsDBNull(rs.GetOrdinal("object_id"))) { _object_id = rs.GetInt32(rs.GetOrdinal("object_id")); } // Original SQL DataType: int
// Inherited if (!rs.IsDBNull(rs.GetOrdinal("principal_id"))) { _principal_id = rs.GetInt32(rs.GetOrdinal("principal_id")); } // Original SQL DataType: int
// Inherited if (!rs.IsDBNull(rs.GetOrdinal("schema_id"))) { _schema_id = rs.GetInt32(rs.GetOrdinal("schema_id")); } // Original SQL DataType: int
// Inherited if (!rs.IsDBNull(rs.GetOrdinal("parent_object_id"))) { _parent_object_id = rs.GetInt32(rs.GetOrdinal("parent_object_id")); } // Original SQL DataType: int
// Inherited if (!rs.IsDBNull(rs.GetOrdinal("type"))) { _type = rs.GetString(rs.GetOrdinal("type")); } // Original SQL DataType: char(2)
// Inherited if (!rs.IsDBNull(rs.GetOrdinal("type_desc"))) { _type_desc = rs.GetString(rs.GetOrdinal("type_desc")); } // Original SQL DataType: nvarchar(60)
// Inherited if (!rs.IsDBNull(rs.GetOrdinal("create_date"))) { _create_date = rs.GetDateTime(rs.GetOrdinal("create_date")); } // Original SQL DataType: datetime
// Inherited if (!rs.IsDBNull(rs.GetOrdinal("modify_date"))) { _modify_date = rs.GetDateTime(rs.GetOrdinal("modify_date")); } // Original SQL DataType: datetime
// Inherited if (!rs.IsDBNull(rs.GetOrdinal("is_ms_shipped"))) { _is_ms_shipped = rs.GetBoolean(rs.GetOrdinal("is_ms_shipped")); } // Original SQL DataType: bit
// Inherited if (!rs.IsDBNull(rs.GetOrdinal("is_published"))) { _is_published = rs.GetBoolean(rs.GetOrdinal("is_published")); } // Original SQL DataType: bit
// Inherited if (!rs.IsDBNull(rs.GetOrdinal("is_schema_published"))) { _is_schema_published = rs.GetBoolean(rs.GetOrdinal("is_schema_published")); } // Original SQL DataType: bit
if (!rs.IsDBNull(rs.GetOrdinal("lob_data_space_id"))) { _lob_data_space_id = rs.GetInt32(rs.GetOrdinal("lob_data_space_id")); } // Original SQL DataType: int
if (!rs.IsDBNull(rs.GetOrdinal("filestream_data_space_id"))) { _filestream_data_space_id = rs.GetInt32(rs.GetOrdinal("filestream_data_space_id")); } // Original SQL DataType: int
if (!rs.IsDBNull(rs.GetOrdinal("max_column_id_used"))) { _max_column_id_used = rs.GetInt32(rs.GetOrdinal("max_column_id_used")); } // Original SQL DataType: int
if (!rs.IsDBNull(rs.GetOrdinal("lock_on_bulk_load"))) { _lock_on_bulk_load = rs.GetBoolean(rs.GetOrdinal("lock_on_bulk_load")); } // Original SQL DataType: bit
if (!rs.IsDBNull(rs.GetOrdinal("uses_ansi_nulls"))) { _uses_ansi_nulls = rs.GetBoolean(rs.GetOrdinal("uses_ansi_nulls")); } // Original SQL DataType: bit
if (!rs.IsDBNull(rs.GetOrdinal("is_replicated"))) { _is_replicated = rs.GetBoolean(rs.GetOrdinal("is_replicated")); } // Original SQL DataType: bit
if (!rs.IsDBNull(rs.GetOrdinal("has_replication_filter"))) { _has_replication_filter = rs.GetBoolean(rs.GetOrdinal("has_replication_filter")); } // Original SQL DataType: bit
if (!rs.IsDBNull(rs.GetOrdinal("is_merge_published"))) { _is_merge_published = rs.GetBoolean(rs.GetOrdinal("is_merge_published")); } // Original SQL DataType: bit
if (!rs.IsDBNull(rs.GetOrdinal("is_sync_tran_subscribed"))) { _is_sync_tran_subscribed = rs.GetBoolean(rs.GetOrdinal("is_sync_tran_subscribed")); } // Original SQL DataType: bit
if (!rs.IsDBNull(rs.GetOrdinal("has_unchecked_assembly_data"))) { _has_unchecked_assembly_data = rs.GetBoolean(rs.GetOrdinal("has_unchecked_assembly_data")); } // Original SQL DataType: bit
if (!rs.IsDBNull(rs.GetOrdinal("text_in_row_limit"))) { _text_in_row_limit = rs.GetInt32(rs.GetOrdinal("text_in_row_limit")); } // Original SQL DataType: int
if (!rs.IsDBNull(rs.GetOrdinal("large_value_types_out_of_row"))) { _large_value_types_out_of_row = rs.GetBoolean(rs.GetOrdinal("large_value_types_out_of_row")); } // Original SQL DataType: bit
if (!rs.IsDBNull(rs.GetOrdinal("is_tracked_by_cdc"))) { _is_tracked_by_cdc = rs.GetBoolean(rs.GetOrdinal("is_tracked_by_cdc")); } // Original SQL DataType: bit
if (!rs.IsDBNull(rs.GetOrdinal("lock_escalation"))) { _lock_escalation = rs.GetByte(rs.GetOrdinal("lock_escalation")); } // Original SQL DataType: tinyint
if (!rs.IsDBNull(rs.GetOrdinal("lock_escalation_desc"))) { _lock_escalation_desc = rs.GetString(rs.GetOrdinal("lock_escalation_desc")); } // Original SQL DataType: nvarchar(60)
if (!rs.IsDBNull(rs.GetOrdinal("is_filetable"))) { _is_filetable = rs.GetBoolean(rs.GetOrdinal("is_filetable")); } // Original SQL DataType: bit
}
catch (Exception Err)
{
throw new Exception("Error occured in the baseclass SqlMetaDataTable_110 as it was loading, please look in the inner exception.", Err);
}
}
#endregion
}
}
With great code, comes great complexity, so keep it simple stupid...
|
|
|
|
 |
This simply outstanding.. excellent tool
Thanks
Md. Marufuzzaman
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
 |
Paw Jershauge,
this generator is one of the best I have found. I know it is not easy to get the time for updating, but We all apreciate very much a new release.
For example, here you are a small inconvenient, when we have especial characters like "ñ" or acents:
throw new Exception("Error setting NombreCompa��a", err);
Regards
ipadilla
|
|
|
|
 |
Hey ipadilla
Thanks alot for the feed back. im glad you like it.
The character you are talking about, are they in the Database, Table, Column, Functions names or ???
best regards..
With great code, comes great complexity, so keep it simple stupid...
|
|
|
|
 |
Thank you Paw for replying,
Yes I am using a spanish database and the names for tables, column, and funcon names can contain acents "á, í, ó ú, é" and characters like "ñ", then the generation code produce lines as:
throw new Exception("Error setting NombreCompa��a", err);
when must be:
throw new Exception("Error setting NombreCompañía", err);
On this lines it is not too much important because it is a message, but I have to change a lot of lines when it is a table, column or function name.
Regards
ipadilla
|
|
|
|
 |
Hey ipadilla
I have not had the time to update the article, yet, but I have made an correcting method to remove those diacritics so that ("á, í, ó ú, é" = "a, i, o, u, e")
internal static string RemoveDiacritics(string obj)
{
char[] chrs = obj.Normalize(NormalizationForm.FormD).ToCharArray();
StringBuilder sb = new StringBuilder();
foreach (char chr in chrs)
{
if (System.Globalization.CharUnicodeInfo.GetUnicodeCategory(chr) != System.Globalization.UnicodeCategory.NonSpacingMark)
sb.Append(chr);
}
return sb.ToString().Normalize(NormalizationForm.FormC);
}
You can add the method to the static class CodeDomGenerator and use it from there. I will when i get the time update the article. but for now, this is what I can help you with... ;o)
Best Regards
With great code, comes great complexity, so keep it simple stupid...
|
|
|
|
 |
Hi Paw,
I going to check it and I'll inform you about the results.
Thank you very much indeed, you are very kind.
ipadilla
|
|
|
|
 |
Hi Paw,
I have added the method to the static class CodeDomGenerator and look up CodeDomHelper.cs and frmMain.cs in order to see the way to use it, but I am not able to get it. Please, can you tell me how to use it?
Thank you
ipadilla
|
|
|
|
 |
ill look into it later today...
With great code, comes great complexity, so keep it simple stupid...
|
|
|
|
 |
I am not sure if I did something wrongs, but I ran against 5 tables (3 source tables and "join" tables) and a view, pulled them into a VB 2008 project and got 102 errors in a few basic types. I doubt it is this broken in general, but not sure what i could have done to break it so. Thanks.
Property 'idSentinelConn' is 'ReadOnly' is reported for fields from the view in Private Sub AddFromRecordSet(ByVal rs As SqlDataReader).
'Public Overloads Property SentinelConn_JobCollection() As SentinelConn_JobCollection' has multiple definitions with identical signatures.
'fld_SentinelConn_JobCollection' is already declared as 'Private fld_SentinelConn_JobCollection As SentinelConn_JobCollection' in this class.
'Is' operator does not accept operands of type 'Boolean'. Operands must be reference or nullable types occurs many times in the tables clases:
Private Sub AddFromRecordSet(ByVal rs As SqlDataReader)
Try
'if value from the recordset, to the idSentinelConn field is NOT null then set the value.
If (rs.IsDBNull(rs.GetOrdinal("idSentinelConn")) Is false) Then
idSentinelConn = rs.GetInt32(rs.GetOrdinal("idSentinelConn"))
End If
Name 'samplets9' is not declared in multiple classes:
Private Function GetSqlParameters() As SqlParameter()
Dim SqlParmColl As List(Of SqlParameter) = New List(Of SqlParameter)
Try
SqlParmColl.Add(samplets9.AddSqlParm("@idSentinelConn", idSentinelConn, SqlDbType.Int))
Karl
|
|
|
|
|
 |
Yes; I output to VB.NET. Otherwise there would be a world of ";" syntax errors.
For what is worth, other than there errors, this looks excellent.
|
|
|
|
|
 |
I'm testing this program against the AdventureWorks2008 database from microsoft and I'm getting all sorts of problems. It looks like the program doesn't work with custom data types. Is there any chance that could be fixed? Otherwise, the program looks cool.
|
|
|
|
 |
Yes the SQLReader does have the ability to cope with custom datatypes. Look in the documentation of the SQLReader there you will see the SQL_Type class which respresents the SQL type even if its an custom type.
Please post the exceptions you get, or and the problems you may encounter. thanks
best regards...
With great code, comes great complexity, so keep it simple stupid...
modified on Friday, July 31, 2009 4:33 AM
|
|
|
|
 |
Ok i found the problem.
Fortunately its not my SQL Reader that contains the error, (besides not having the correct error handle for this bug in the new AdventureWorks2008)
There are 3 new datatypes called hierarchyid, geometry, geography which causes the program to fail. they have no base datatype , which ALL custom datatypes need to have. , and these new datatypes can not be mapped into .Net (look here for more Mapping CLR Parameter Data[^])
So to correct this and get the program back online heres the following fixes
Find the Types.cs file and replace the following code:
public Type NetType
{
get
{
if (_system_type_id == _user_type_id)
{
return GetTypeFromName(_name);
}
else
{
SQL_Type SQLT = _Owner.GetSQLSystemType(_system_type_id);
if (SQLT != null)
return GetTypeFromName(SQLT.name);
else
return typeof(object);
}
}
}
and this code block (to cope with the new dataypes like datetime2,date,time and so on...):
private Type GetTypeFromName(string Tname)
{
switch (Tname.ToLower())
{
case "bigint": return typeof(System.Int64);
case "binary": return typeof(System.Byte).MakeArrayType();
case "bit": return typeof(System.Boolean);
case "char": return typeof(System.String);
case "date": return typeof(System.DateTime);
case "datetime": return typeof(System.DateTime);
case "datetime2": return typeof(System.DateTime);
case "datetimeoffset": return typeof(System.DateTimeOffset);
case "decimal": return typeof(System.Decimal);
case "float": return typeof(System.Double);
case "image": return typeof(System.Object);
case "int": return typeof(System.Int32);
case "money": return typeof(System.Decimal);
case "nchar": return typeof(System.String);
case "ntext": return typeof(System.String);
case "numeric": return typeof(System.Decimal);
case "nvarchar": return typeof(System.String);
case "real": return typeof(System.Single);
case "smalldatetime": return typeof(System.DateTime);
case "smallint": return typeof(System.Int16);
case "smallmoney": return typeof(System.Decimal);
case "sql_variant": return typeof(System.Object);
case "text": return typeof(System.String);
case "time": return typeof(System.TimeSpan);
case "timestamp": return typeof(System.Object);
case "tinyint": return typeof(System.Byte);
case "uniqueidentifier": return typeof(System.Guid);
case "varbinary": return typeof(System.Byte).MakeArrayType();
case "varchar": return typeof(System.String);
case "xml": return typeof(System.String);
default: return null;
}
}
I will when i get the time correct this in the souce code files, and repost it ;o)
Thanks for posting the error zephyrprime
With great code, comes great complexity, so keep it simple stupid...
|
|
|
|
 |
Great product. Just downloaded it and generated classes. However where is the method "AddSqlParm". Am I missing something? Should it not be a method of the generated class. Obviously I can't run anything. Language being used is VB.Net 2008. Thanks much.
|
|
|
|
|
 |
I also did not find AddSqlParm function. Please tell me where can I find it?
|
|
|
|
|
 |
Thnx Paw for sharing.
I'm new in .NET. For 10 years I've developed DB app in VB6, but it's time to leave vb6 and go to the .NET.
Your approach is very interesting, but (I feel like a child) I'm new to .NET and I'm having a hard time to follow.
Can You Please put some sample application? No complicated simple so that we (the bottom begginers in .NET can feel like a profi from VB6).
Regards,
Davor
|
|
|
|
|
 |
This tool is really good. An application sample would be appreciated.
My rate EXCELLENT
ipadilla
|
|
|
|
 |
Hi! Very good tool!
I just want to notify an error.
I'm running the tool on SQL Server 2008 and I got an error after the scan of a databases.
In particular the tool hangs when it try to scan a SQL 2000 database.
The database has been attached and changed the compatibility mode to 2005.
I try to detach the database and everything works.
Here is the error debug:
System.Data.SqlClient.SqlException: Invalid object name 'sys.index_Columns'.
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.ExecuteReader()
at SQLReader.IndexColumns..ctor(SqlConnectionStringBuilder SQLConnSetting, Index owner)
at SQLReader.Indexes..ctor(SqlConnectionStringBuilder SQLConnSetting, Table owner)
at SQLReader.Table..ctor(SqlConnectionStringBuilder SQLConnSetting, SqlDataReader rs, Tables owner)
at SQLReader.Tables..ctor(SqlConnectionStringBuilder SQLConnSetting, Database owner)
at SQLReader.Database.LoadAssociatedObjects(SqlConnectionStringBuilder SQLConnSet)
at SQLReader.Databases.InitObject(SqlConnectionStringBuilder SQLConnSetting, SQLServer owner, String catalog, LoadingAssociatedObjects loadingdatabase)
at SQLReader.SQLServer.LoadDatabases(String catalog)
at SQLReader.SQLServer.LoadDatabases()
at SQL2ClassDemo.frmMain.bntConnect_Click(Object sender, EventArgs e) in C:\Documents and Settings\Paw\Skrivebord\SQL2Class\SQL2Class\SQL2ClassDemo\frmMain.cs:line 94
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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Thanks!
Nicola
|
|
|
|
 |
Hi Nicolaz
Thanks alot for that. i haven't had the time to update the article for a long time now, ive been busy... sorry.
I think you error is because the database is comming from an SQL 2000 version. This program only works on 2005 and 2008 versions of the server instance and now clearly also only on compatible mode versions from 2005 and upwards..
I guess when you import the database in an old version, all the META element are not created on the server, thats why you get this error.
NOTE: The Program will always Fail/Hang on SQL 2000.
Best regards
With great code, comes great complexity, so keep it simple stupid...
|
|
|
|
 |
Hey nicolaz, again
I've been investigating your error, and i found a very funny twist to this error message.
I would bet that your database was in an CS (Case Sensitive) state Collation. please follow up on that.
So the fix for this, is to edit my SQLReader.
Here are the four classes that needs to be edited:
- IndexColumn
- IndexColumns
- IdentityColumn
- IdentityColumns
in all the select commands of these classes, make the (FROM) table names lower case, where as i currently use FROM sys.index_Columns (Note: the upper case "C" in columns), this should be an lower case "c" like this FROM sys.index_columns .
I will correct this an upload a newer version Friday, 9 jan 2009, so watch out for that... (ITS UPDATED!!!!)
Ones again thanks for posting this...
Best regards
With great code, comes great complexity, so keep it simple stupid...
modified on Friday, January 9, 2009 3:43 AM
|
|
|
|
 |
Thanks Paw. You saved me from certain death.
(Lol).
Where there's smoke, there's a Blue Screen of death.
|
|
|
|
|
|
 |
Hello. It's very impressive.
I want to deal with stored procedure using your project.
But I thought that it's not supported.
If you would answer to me a question, I will appreciate it.
|
|
|
|
 |
I havnt made so that the source code can handle Stored Procedures.
This code generator ONLY generates the shell for the Tables (and upcomming Views).
What would have the generator do????
let me know if i can help.
With great code, comes great complexity, so keep it simple stupid...
|
|
|
|
 |
Love the utility!
Just a thought... It would be nice if you could also had the ability to export Views, providing a read-only collection object through the generated DAL.
Thanks!
|
|
|
|
 |
I havnt been working alot with Views, but you are right, this shouldnt be any problem.
i will keep it in mind, when upgrading the source code shortly...
Thanks 4 the reply...
best regards
With greate code, comes greate complexity, so keep it simple stupid...
|
|
|
|
 |
Ok so i tested the View Objects, and it seems to be working...
just to be clear on this... the class generated from this view, will be read only, right? i mean there is no reason to make it anyway other, since its an View. Correct me here, if im wrong.
With great code, comes great complexity, so keep it simple stupid...
|
|
|
|
|
 |
|
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.
|
- Code Generation 2008 Competition (Second Prize)
First Posted | 16 Jul 2008 |
|
|