DotNet

SQL Connection example

private void GP_Click(object sender, System.EventArgs e) {
string strResult = string.Empty;
string MyConString = "SERVER=localhost;" + "DATABASE=database;" + "UID=user;" + "PWD=PWD;";
SqlConnection con = new SqlConnection(MyConString);
SqlCommand cmd = con.CreateCommand();
cmd.CommandText = "select * from mycustomers";
con.Open();
strResult = cmd.ExecuteReader().ToString();
con.Close();
}
Dynamic Query example

DECLARE @TABNAME VARCHAR(100)
DECLARE @QRY VARCHAR(100)
DECLARE @ICAPBatchId INT
SELECT B.ImageName AS ImageName, B.BatchId, B.ICAPBatchId AS ICAPBatchId, B.DocumentId ,B.DocTypeConfigId,
D.MQServer,D.MQTimeOut,D.VerifyQName,D.HeaderTableName
FROM tblICAPBatchInfo AS B
LEFT OUTER JOIN tblDocTypeConfiguration AS D ON B.DocTypeConfigId=D.DocTypeConfigId
WHERE B.DocTypeConfigId='1' AND B.IsActive=1
SELECT @TABNAME=D.HeaderTableName,@ICAPBatchId=B.ICAPBatchId
FROM tblICAPBatchInfo AS B
LEFT OUTER JOIN tblDocTypeConfiguration AS D ON B.DocTypeConfigId=D.DocTypeConfigId
WHERE B.BatchId='05072012\05072012.0091' AND B.IsActive=1
SET @QRY='SELECT * FROM '+@TABNAME+' WHERE IsActive=1 AND ICAPBatchId='+CAST(@ICAPBatchId as varchar)
EXEC(@QRY)
declare @tblname varchar(100) set @tblname='tbluser' declare @qry varchar(max) declare @colnames varchar(1000) set @colnames='UserName,Password,*' set @qry='select '+@colnames+' from '+@tblname exec(@qry)


Ajax (Asynchronous JavaScript and XML)
Ajax (Asynchronous JavaScript and XML) is a method of building interactive applications for the Web that process user requests immediately. Ajax combines several programming tools including JavaScript, dynamic HTML (DHTML), Extensible Markup Language (XML), cascading style sheets (CSS), the Document Object Model (DOM), and the Microsoft object, XMLHttpRequest. Ajax allows content on Web pages to update immediately when a user performs an action, unlike an HTTP request, during which users must wait for a whole new page to load. For example, a weather forecasting site could display local conditions on one side of the page without delay after a user types in a zip code. Google Maps is one well-known application that uses Ajax. The interface allows the user to change views and manipulate the map in real time. Ajax applications do not require installation of a plug-in, but work directly with a Web browser. Because of the technique's reliance on XMLHttpRequest, early applications worked only with Microsoft's Internet Explorer browser, but most other browsers now support Ajax. Applications created with Ajax use an engine that acts as an intermediary between a user's browser and the server from which it is requesting information. Instead of loading a traditional Web page, the user's browser loads the Ajax engine, which displays the page the user sees. The engine continues to run in the background, using JavaScript to communicate with the Web browser. User input or clicking on the page sends a JavaScript call to the Ajax engine, which can respond instantly in many cases. If the engine needs additional data, it requests it from the server, usually using XML, while it is simultaneously updating the page. Ajax is not a proprietary technology or a packaged product. Web developers have been using JavaScript and XML in combination for several years. Jesse James Garrett of the consultancy firm Adaptive Path is credited with coining the name "Ajax" as a shorthand way to refer to the specific technologies involved in a current approach.

No comments:

Post a Comment