Posts

Donate

Bulk Insert Stored Procedure Not Returning 0 Row(s) Affected (Error)

Lately, A while ago, a friend of mine sent me a CSV file whose fields are separated by comma. I followed a link from http://www.sqlteam.com in creating a stored procedure via BULK INSERT. This complex stored procedure inserts rows from a csv file to a database table with a field defined as primary key (identity seed option set). After changing the script from the website and executed the SP below: use clientdb go EXEC Customer_Import 'D:\Csharp progs\Orders\Client.csv' , 2 The message returned in the result pane was: 0 row(s) affected. Wow, how could this happend where in fact, the csv has 50 rows? I've changed other options to the SP but got no luck. The solution i ran into was to re-open the CSV file and save as another file. Ex. (from Client to Client1). So, when i executed the SP above using the other file, it performed perfectly. use clientdb go EXEC Customer_Import 'D:\Csharp progs\Orders\Client1.csv' , 2 So, I guess there mu

Printing Checkboxes In Crystal Reports.NET

Image
Source: Crystal Reports To display a checkbox on the report, create a new formula field and insert the following formula. If {Field} = True Then 'Display the checkbox of your choice here Formula = Chr( 254 ) Else 'Display empty checkbox Formula = Chr( 168 ) End If

How To Create A Database Schema In SQL Server

Source: http://msdn.microsoft.com/en-us/library/dd207005.aspx In recent versions of sql server specifically 2005 and 2008, the database called Adventure works seems to be a good example with lots of tables to play with. When I tried to open the database, the tables have prefix or have namespace before it. Example: HumanResources.EmployeeAddress In the previous example called northwind and pubs,table names were just one word. So, to create a schema, here's how to do it: create schema < schema_name > go alter schema < schema_name > transfer <dbo.yourtable> go -- show table select * from schema_name .tablename

Ambigous Column Name In SQL Server TSQL Query

If you encounter this error in your TSQL query embedded in C#, you might want to check the table it is being joined. It might be that some field in the other table has the same fieldname. Example Orders - status varchar(90) OrdersSubForm - status varchar(30) Just make sure, you create a prefix of the table name plus the dot and append it in your field. Just like the example below, for the status field. Select Orders.status, OrderNum from Orders right outer join OrderSubForm on OrderSubForm.ID = Orders.ID where (your condition here)

How To Sort DataTable In C# Or VB.NET

Sorting a data table before binding to a data control like gridview or datalist is provided by microsoft through it's predefined methods which is defaultview.sort. Example: //C# dt1.DefaultView.Sort = "Name Desc" ; //VB.NET dt1.DefaultView.Sort = "Name Desc" Where dt1 is your datatable. Or you could create a dataview object as provided by MSDN. Source: MSDN

Ajax Control PopupControlExtender GetProxyForCurrentPopup Not Showing In Visual Studio Intellisense

I was wondering why when I type PopupControlExtender. nothing happens. Supposedly, GetProxyForCurrentPopup method will show. The solution was so simple, I forgot to include the namespace of AjaxControlsToolkit. //add namespace AjaxToolkit using AjaxControlToolkit; //call commit method PopupControlExtender pce = PopupControlExtender.GetProxyForCurrentPopup( this ); pce.Commit( "hi" );

JavaScript Object Oriented Programming Using Prototype

Hello, In JavaScript, each Object can inherit properties from another object, called it's prototype . When evaluating an expression to retrieve a property, JavaScript first looks to see if the property is defined directly in the object. If it is not, it then looks at the object's prototype to see if the property is defined there. This continues up the prototype chain until reaching the root prototype. Each object is associated with a prototype which comes from the constructor function from which it is created. (Source: http://mckoss.com/jscript/object.htm ) Here's an example i created: <html> <head> <script type= "text/javascript" language= "javascript" > function NumberManip() { var result = 0; } NumberManip.prototype.add = function (num1, num2) { this .result = num1 + num2; } NumberManip.prototype.subtract = function (num1, num2) { this .result = num1 - num2; }

Inner Joins In SQL Server TSQL

Source: TSQL Programming Reference: An inner join applies two logical query processing phases—it applies a Cartesian product between the two input tables like a cross join, and then it filters rows based on a predicate that you specify. Like cross joins, inner joins have two standard syntaxes: ANSI SQL-92 and ANSI SQL-89. Using the ANSI SQL-92 syntax, you specify the INNER JOIN keywords between the table names. The INNER keyword is optional because an inner join is the default, so you can specify the JOIN keyword alone. You specify the predicate that is used to filter rows in a designated clause called ON. This predicate is also known as the join condition. Here are two basic implementations of inner join scripts i created, one with the inner keyword, and the other w/o the inner keyword. select distinct l.LoanNum, ( c .CusLastName + ', ' + c .CusFirstName + ' ' + c .CusMiddleInit) as Name, Status, DateGranted, AmountGranted from

ASP.NET Web Forms GridView RowUpdating Event Not Getting New Values From Controls

I have a code in rowupdating event which get's values from textbox controls during edit mode. However, when update command button is clicked, the values from the controls were cleared or null. So, I checked the page load event, and found out that I have a code which rebinds the grid when it is not post back since the update link button will trigger postback. Here is the page load code: if (! string .IsNullOrEmpty(Request.QueryString[ "LoanNum" ])) { ShowToControls(Convert.ToInt32(Request.QueryString[ "LoanNum" ])); BindGridDetails(Convert.ToInt32(Request.QueryString[ "LoanNum" ])); } So, the modified pageload code should add a IsPostback condition so that the binding of gridview will not be executed. Here's the modified script: if (! string .IsNullOrEmpty(Request.QueryString[ "LoanNum" ]) && !Page.IsPostBack) { ShowToControls(Convert.ToInt32(Request.QueryString[ "LoanNum" ])); BindGridDe

Online Syntax Highlighter For Code Posts

As I reviewed my blog, the code snippets seems to be a mess and unpresentable. So I did some googling earlier and found some online syntax highlighter that may come in handy. https://tohtml.com/jScript/ https://quickhighlighter.com/ https://hilite.me

Donate