studio NETSOULS

Applying Web To Your Business

When searching for this I found dozens of implementations doing things like parsing each character, string manipulation, and more. But one of the best solutions i could come up is this:

   1: function isInteger(val) {
   2:  
   3:    return (val == null || isNaN(val)) ? false : 
   4:       ( ((1.0 * val) == Math.floor(val)) && (val.indexOf(".") == -1));
   5:  
   6: }
  • Currently 4 /5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Sometimes you may want to pass a comma separated string as an argument to stored procedure or SQL function and parse within the procedure. This sample code shows how to parse a string based any delimiter you specify.

CREATE FUNCTION dbo.CreateInlineTable (
    @Param AS VARCHAR(7999), -- Deliminated string
    @Deliminator AS VARCHAR(10) -- Deliminator
    )   RETURNS TABLE
AS
    RETURN ( SELECT Substring(@Deliminator + @Param + @Deliminator, Number + LEN(@Deliminator), 
                    CHARINDEX(@Deliminator, @Deliminator + @Param + @Deliminator, Number + LEN(@Deliminator)) - Number - LEN(@Deliminator) ) AS PARAM
               FROM InlineNumbers Numbers
              WHERE Number <= LEN(@Deliminator + @Param + @Deliminator) - LEN(@Deliminator)
                    AND Substring(@Deliminator + @Param + @Deliminator, Number,LEN(@Deliminator)) = @Deliminator)
 
GO

More...

  • Currently 0 /5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

   1: /// <summary>
   2: /// Converts a DataTable to a string with an html table.
   3: /// </summary>
   4: /// <returns></returns>
   5: public static string DataTableToString(DataTable datatable, bool headers)
   6: {
   7:     StringBuilder sb = new StringBuilder();
   8:  
   9:     sb.Append("<table border=\"1\">");
  10:  
  11:     if (headers)
  12:     {
  13:         //write column headings
  14:         sb.Append("<tr>");
  15:         foreach (DataColumn datacolumn in datatable.Columns)
  16:         {
  17:             sb.Append("<td>" + datacolumn.ColumnName + "</td>");
  18:         }
  19:         sb.Append("</tr>");
  20:     }
  21:  
  22:     //write table data
  23:     foreach (DataRow datarow in datatable.Rows)
  24:     {
  25:         sb.Append("<tr>");
  26:         foreach (DataColumn datacolumn in datatable.Columns)
  27:         {
  28:             sb.Append("<td>" + datarow[datacolumn].ToString() + "</td>");
  29:         }
  30:         sb.Append("</tr>");
  31:     }
  32:     sb.Append("</table>");
  33:  
  34:     return sb.ToString();
  35: }
  • Currently 0 /5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

When dealing with MS SQL (not MYSQL) I’ve seen this error message before, but found very little help on it out there.

The log file for database db_name is full. Back up the transaction log for the database to free up some log space.

Within the MS SQL Query Analyzer, do this:
 

   1: backup log db_name with truncate_only 
   2: go 
   3: dbcc shrinkfile (db_name_log,0) 
   4: go

If anything, this post will be useful for me in the future when one of my MS SQL databases coughs up the error again.

  • Currently 0 /5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

About Us

studio NETSOULS is a complete IT services company, offering strategy, design, development and implementation of the total solution for your web and IT initiatives. The solutions we provide, enables businesses to leverage leading edge technology to gain sustainable competitive advantages in today's marketplace.

We specialize in designing, developing and deploying the next generation of IT solutions including e-business solutions Read more...

Tags

This will be shown to users with no Flash or Javascript.

Contact Us

My status

Quote of the Day

Men are disturbed, not by the things that happen, but by their opinion of the things that happen

- Epictetus

NutritionVista

www.NutritionVista.com

Archives


Advertisements


Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

Log in