Knowledge Base Category: Development

How do I record the primary key of an inserted record

The table must have a PrimaryKey Note that the best way to do this is by creating a store procedure that returns the Primary Key Make sure your SQLDataSource has the output parameter: [tp no_translate="y"]

InsertCommand="INSERT INTO [Orders] ([UserID], [Total], [OrderDate]) 
VALUES (@UserID, @Total, {fn NOW()}); Select... 						
						
Read more

How can I create a dynamic table?

I wrote this script long time ago, the option to xml table didnt exist at the time. I recommend another solution such as query to xml. However here is the code [tp no_translate="y"]

DROP TABLE #payments 
DROP TABLE ##mytable
DROP TABLE  #paymentHistory
CREATE TABLE #paymentHistory(id INT,amount DECIMAL (9,2),DATE smalldatetime)
INSERT INTO #paymentHistory
VALUES (1,'300','01/01/08')
INSERT INTO #paymentHistory
VALUES (1,'350','01/02/08')
INSERT INTO #paymentHistory
VALUES... 						
						
Read more

How to bypass crystal login information, set parameters and print to pdf?

1) Create a page with a print button, a submitt button, and a crytal report viewer we are naming it CVWSales
2)Create a Crystal report [.RPT] file with its SQL connection.
Here is the code. [tp no_translate="y"]
Imports System.Data.SqlClient
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CrystalDecisions.CrystalReports.Engine.PrintOptions

Partial Class ReportViewer
    Inherits System.Web.UI.Page

   
    Dim... 						
						
Read more

How to encode html to replace special characters

A simple function that will replace all your html tags into character code great for storing HTML in XML tags:  

VB Code

Public Function encoder(htmlcode As String) As String 
Dim writer As New IO.StringWriter 
Server.HtmlEncode(htmlcode, writer) 
Dim result As String = writer.ToString 
Return result 
End Function

C# Code

Read more