Exforsys

Home arrow Technical Training arrow ASP.NET Training

ASP .NET Migration and Interoperability Page - 2

Page 2 of 2
Author : Exforsys Inc.     Published on: 24th Apr 2005    |   Last Updated on: 29th Mar 2007

ASP .NET Migration and Interoperability




strSQLQuery = "DELETE * FROM tablename WHERE Name = 'Fred' AND Address = 'Smith St'"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strSQLQuery, conn, 3, 3

Ads


strSQLQuery = "DELETE * FROM tablename WHERE Name = 'Fred' OR Name = 'John'"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strSQLQuery, conn, 3, 3



strSQLQuery = "UPDATE tablename SET FieldName1 = " & strValue1 & " WHERE FieldName2 = " & strValue2 & ";"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strSQLQuery, conn, 3, 3



strSQLQuery = "INSERT INTO tablename (FieldName1, FieldName2) VALUES (" & strValue1 & ", " & strValue2 & ")"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strSQLQuery, conn, 3, 3

Using Platform Invocation Services

Platform Invocation Services (PInvoke) allows managed code to call unmanaged functions that are implemented in a DLL.

Ads

This tutorial shows you what you need to do to be able to call unmanaged DLL functions from C#. The attributes discussed in the tutorial allow you to call these functions and have data types be marshaled correctly.

This is a simple example that shows how you can use the DllImport to import any dll file using C# code.

Platform Invocation Services (PInvoke) allows managed code to call unmanaged functions that are implemented in a DLL.

This tutorial shows you what you need to do to be able to call unmanaged DLL functions from C#. The attributes discussed in the tutorial allow you to call these functions and have data types be marshaled correctly.

This is a simple example that shows how you can use the DllImport to import any dll file using C# code.

// PInvokeTest.cs
using System;
using System.Runtime.InteropServices;

class PlatformInvokeTest
{
[DllImport("msvcrt.dll")]
public static extern int puts(string c);
[DllImport("msvcrt.dll")]
internal static extern int _flushall();

public static void Main()
{
puts("Test");
_flushall();
}
}


This example shows that how you can use DllImport to produce string.
// Marshal.cs
using System;
using System.Runtime.InteropServices;

class PlatformInvokeTest
{
[DllImport("msvcrt.dll")]
public static extern int puts(
[MarshalAs(UnmanagedType.LPStr)]
string m);
[DllImport("msvcrt.dll")]
internal static extern int _flushall();


public static void Main()
{
puts("Hello World!");
_flushall();
}
}

I hope you liked the tutorial and in the next tutorial we will learn about Session variables which are used to pass values arround.




 
This tutorial is part of a ASP.NET Training tutorial series. Read it from the beginning and learn yourself.

ASP.NET Training

 

Comments