データベース接続


  MDB : System.Data.OleDb( Framework )




  

Imports System.Data.OleDb

Module MyModule

' ********************************************************
' 実行
' ********************************************************
Sub Main()

	Dim myConnectString As String = _
		"Provider=Microsoft.Jet.OLEDB.4.0;" + _
		"Data Source=C:\Program Files\WinOfSql\Tool\parts\販売管理.mdb;"
	Dim myCon As New OleDbConnection()
	myCon.ConnectionString = myConnectString
	myCon.Open()

	Dim myQuery As String = "SELECT * from 社員マスタ"
	Dim myCommand As New OleDbCommand()
	myCommand.CommandText = myQuery
	myCommand.Connection = myCon

	Dim myReader As OleDbDataReader
	myReader = myCommand.ExecuteReader()
	Dim fld As Integer = 0
	Do While myReader.Read()
		fld = myReader.GetOrdinal("氏名")
		Console.WriteLine(myReader.GetString(fld))
	Loop
	myReader.Close()
	myCon.Close()

End Sub

End Module
  

  Excel : System.Data.OleDb( Framework )




  

Imports System.Data.OleDb

Module MyModule

' ********************************************************
' 実行
' ********************************************************
Sub Main()

	Dim myConnectString As String = _
	"Provider=Microsoft.Jet.OLEDB.4.0;" + _
	"Data Source=C:\Documents and Settings\lightbox\My Documents\社員マスタ.xls;" + _
	"Extended Properties=""Excel 8.0;IMEX=1;"""

	Dim myCon As New OleDbConnection()
	myCon.ConnectionString = myConnectString
	myCon.Open()

	Dim myQuery As String = "SELECT * from 社員マスタ"
	Dim myCommand As New OleDbCommand()
	myCommand.CommandText = myQuery
	myCommand.Connection = myCon

	Dim myReader As OleDbDataReader
	myReader = myCommand.ExecuteReader()
	Dim fld As Integer = 0
	Do While myReader.Read()
		fld = myReader.GetOrdinal("氏名")
		Console.WriteLine(myReader.GetString(fld))
	Loop
	myReader.Close()
	myCon.Close()

End Sub

End Module
  

  MySQL : System.Data.Odbc( Framework )

MySQL 4.1 以上の場合、データベースのキャラクタセットが何であっても、
クライアントのキャラクタセットを以下のように接続時に指定する事ができるはずです。
( ソースコード例では、myCommand.ExecuteNonQuery() で実行する )

【Shift_JIS の場合】
set names 'sjis'

【EUC-JP の場合】
set names 'ujis'


※ テーブル名に Shift_JIS が使用できるのは、MySQL5.1 以降のようです

  

' ********************************************************
' ■ MySQL データベースアクセス
' ********************************************************
Imports System.Data.Odbc

Module MyModule

' ********************************************************
' MySQL / System.Data.Odbc
' ********************************************************
Sub Main()

	Dim myConnectString As String = _
		"Driver={MySQL ODBC 5.1 Driver};" + _
		"SERVER=localhost;" + _
		"DATABASE=lightbox;" + _
		"UID=root;" + _
		"PWD=password"

	Dim myCon As New OdbcConnection()
	myCon.ConnectionString = myConnectString
	myCon.Open()

	Dim myQuery As String = _
		"SELECT 社員マスタ.*,DATE_FORMAT(生年月日,'%Y-%m-%d') as 誕生日" _
		+ " from 社員マスタ"
	Dim myCommand As New OdbcCommand()
	myCommand.CommandText = myQuery
	myCommand.Connection = myCon

	Dim myReader As OdbcDataReader
	myReader = myCommand.ExecuteReader()

	Do While myReader.Read()

		' 文字列
		Console.Write(GetValue(myReader,"社員コード") + " : ")
		Console.Write(GetValue(myReader,"氏名") + " : ")

		' 整数
		Console.Write(GetValue(myReader,"給与") + " : ")

		' 日付
		Console.Write(GetValue(myReader,"作成日") + " : ")
		Console.Write(GetValue(myReader,"更新日") + " : ")
		Console.Write(GetValue(myReader,"生年月日") + " : ")
		Console.Write(GetValue(myReader,"誕生日"))
		Console.WriteLine()

	Loop

	myReader.Close()

	myQuery = "update 社員マスタ set 生年月日 = '1982/01/01'" _
		+ " where 社員コード = '0002'"
	Execute( myCon, myQuery )

	myCon.Close()

	myReader.Dispose()
	myCon.Dispose()

End Sub

' ********************************************************
' 列データ取得
' ********************************************************
Function GetValue(ByVal odr As OdbcDataReader, _
	ByVal strName As String) As String

	Dim ret As String = ""
	Dim fld As Integer = 0

	fld = odr.GetOrdinal(strName)
	If odr.IsDBNull(fld) Then
		ret = ""
	Else
		ret = odr.GetValue(fld).ToString()
	End If

	Return ret

End Function

' ********************************************************
' 更新処理
' ********************************************************
Function Execute(ByVal cn As OdbcConnection, _
	ByVal SQL As String) As Integer

		Dim ret As Integer
		Dim execCommand As OdbcCommand = New OdbcCommand()

		execCommand.CommandText = SQL
		execCommand.Connection = cn
		Try
			ret = execCommand.ExecuteNonQuery()
		Catch ex As Exception
			Console.WriteLine( ex.Message )
		End Try
		execCommand.Dispose()

		Return ret

End Function

End Module
  

  Oracle 10g : System.Data.Odbc( Framework ) : Microsoft Driver

Oracle は、いろいろ試しましたが、結局 Microsoft のドライバが最も安定しています

  

Imports System.Data.Odbc

Module MyModule

' ********************************************************
' 実行
' ********************************************************
Sub Main()

	Dim myConnectString As String = _
		"Driver={Microsoft ODBC for Oracle};" + _
		"SERVER=localhost/ORCL;" + _
		"UID=lightbox;" + _
		"PWD=lightbox"
	Dim myCon As New OdbcConnection()
	myCon.ConnectionString = myConnectString
	myCon.Open()

	Dim myQuery As String = "SELECT * from 社員マスタ"
	Dim myCommand As New OdbcCommand()
	myCommand.CommandText = myQuery
	myCommand.Connection = myCon

	Dim myReader As OdbcDataReader
	myReader = myCommand.ExecuteReader()
	Dim fld As Integer = 0
	Do While myReader.Read()
		fld = myReader.GetOrdinal("氏名")
		Console.WriteLine(myReader.GetString(fld))
	Loop
	myReader.Close()
	myCon.Close()

End Sub

End Module
  

  PostgreSQL : System.Data.Odbc( Framework ) : http://www.postgresql.jp/

  

Imports System.Data.Odbc

Module MyModule

' ********************************************************
' 実行
' ********************************************************
Sub Main()

	Dim myConnectString As String = _
		"Driver={PostgreSQL Japan};" + _
		"SERVER=localhost;" + _
		"DATABASE=lightbox;" + _
		"UID=postgres;" + _
		"PWD=password"
	Dim myCon As New OdbcConnection()
	myCon.ConnectionString = myConnectString
	myCon.Open()

	Dim myQuery As String = "SELECT * from 社員マスタ"
	Dim myCommand As New OdbcCommand()
	myCommand.CommandText = myQuery
	myCommand.Connection = myCon

	Dim myReader As OdbcDataReader
	myReader = myCommand.ExecuteReader()
	Dim fld As Integer = 0
	Do While myReader.Read()
		fld = myReader.GetOrdinal("氏名")
		Console.WriteLine(myReader.GetString(fld))
	Loop
	myReader.Close()
	myCon.Close()

End Sub

End Module
  

  SQLServer : System.Data.OleDb( Framework )

2000 以降では、インスンタンス指定で マシンID\インスタンス名 を Data Source に指定できます
また、SQLServer は、専用のクラス( System.Data.SqlClient ) があります
さらに、System.Data.Odbc でも接続可能です

↓接続文字列のオプション( Windows 認証等 )
http://msdn.microsoft.com/ja-jp/library/ms254978(VS.80).aspx

  

Imports System.Data.OleDb

Module MyModule

' ********************************************************
' 実行
' ********************************************************
Sub Main()

	Dim myConnectString As String = _
		"Provider=SQLOLEDB;" + _
		"Data Source=layla;" + _
		"Initial Catalog=mydb;" + _
		"User ID=sa;" + _
		"Password=;"
	Dim myCon As New OleDbConnection()
	myCon.ConnectionString = myConnectString
	myCon.Open()

	Dim myQuery As String = "SELECT * from 社員マスタ"
	Dim myCommand As New OleDbCommand()
	myCommand.CommandText = myQuery
	myCommand.Connection = myCon

	Dim myReader As OleDbDataReader
	myReader = myCommand.ExecuteReader()
	Dim fld As Integer = 0
	Do While myReader.Read()
		fld = myReader.GetOrdinal("氏名")
		Console.WriteLine(myReader.GetString(fld))
	Loop
	myReader.Close()
	myCon.Close()

End Sub

End Module
  

  SQLServer : System.Data.SqlClient( Framework )

  

Imports System.Data.SqlClient

Module MyModule

' ********************************************************
' 実行
' ********************************************************
Sub Main()

	Dim myConnectString As String = _
		"Data Source=localhost;" + _
		"Initial Catalog=mydb;" + _
		"User ID=sa;" + _
		"Password=;"
	Dim myCon As New SqlConnection()
	myCon.ConnectionString = myConnectString
	myCon.Open()

	Dim myQuery As String = "SELECT * from 社員マスタ"
	Dim myCommand As New SqlCommand()
	myCommand.CommandText = myQuery
	myCommand.Connection = myCon

	Dim myReader As SqlDataReader
	myReader = myCommand.ExecuteReader()
	Dim fld As Integer = 0
	Do While myReader.Read()
		fld = myReader.GetOrdinal("氏名")
		Console.WriteLine(myReader.GetString(fld))
	Loop
	myReader.Close()
	myCon.Close()

End Sub

End Module
  

  SQLServer : System.Data.Odbc( Framework )

  

Imports System.Data.Odbc

Module MyModule

' ********************************************************
' 実行
' ********************************************************
Sub Main()

	Dim myConnectString As String = _
		"Driver={SQL Server};" + _
		"SERVER=localhost;" + _
		"DATABASE=mydb;" + _
		"UID=sa;" + _
		"PWD="
	Dim myCon As New OdbcConnection()
	myCon.ConnectionString = myConnectString
	myCon.Open()

	Dim myQuery As String = "SELECT * from 社員マスタ"
	Dim myCommand As New OdbcCommand()
	myCommand.CommandText = myQuery
	myCommand.Connection = myCon

	Dim myReader As OdbcDataReader
	myReader = myCommand.ExecuteReader()
	Dim fld As Integer = 0
	Do While myReader.Read()
		fld = myReader.GetOrdinal("氏名")
		Console.WriteLine(myReader.GetString(fld))
	Loop
	myReader.Close()
	myCon.Close()

End Sub

End Module
  

  MySQL : java ( mysql-connector-java-5.0.6-bin.jar )

  

import java.sql.*;

public class mysql {

	public static void main(String[] args) {

		Connection con;
		Statement stmt;
		ResultSet rset;

// *********************************************************
// MySQL 5.1
// mysql-connector-java-5.0.6-bin.jar
// *********************************************************
		try {
			Class.forName("com.mysql.jdbc.Driver");
			con = DriverManager.getConnection(
				"jdbc:mysql://localhost/lightbox"
				+"?user=root"
				+"&password="
// *********************************************************
// 以下が無い場合、日本語指定の getString が失敗する
// *********************************************************
				+"&characterSetResults=sjis"
			);
			stmt = con.createStatement();

			rset = stmt.executeQuery ( "select * from `社員マスタ`" );

			ResultSetMetaData rm = rset.getMetaData();
			int nCols = rm.getColumnCount();
			String[] data = new String[nCols];
			int i;

			while( rset.next() ) {
				System.out.print( rset.getString( "氏名" ) + ":" );
				for( i = 0; i < nCols; i++ ) {
					data[i] = rset.getString( i+1 );

					if ( i != 0 ) {
						System.out.print( "," );
					}
					System.out.print( data[i] );
				}
				System.out.println(  );
			}

			stmt.close();
			con.close();

		}
		catch (Exception e) {
			System.out.println( e.getMessage() );
		}

	}
}
  

更新処理
  

// *****************************************************
// DB 更新処理
// *****************************************************
public int Execute( String Query ) {

	ErrorMessage = "";

	int nRet;

	try {
		nRet = stmt.executeUpdate( Query );
	}
	catch( SQLException e ) {
		ErrorMessage = e.getMessage();
		return -1;
	}

	return nRet;

}
  

  MySQL : java ( JDBC-ODBC ブリッジドライバ )

http://dev.mysql.com/doc/refman/5.0/en/myodbc-configuration-connection-parameters.html

  

import java.sql.*;

public class mysql_odbc {

	public static void main(String[] args) {

		Connection con;
		Statement stmt;
		ResultSet rset;

// *********************************************************
// odbc 用 jdbc
// *********************************************************
		try {
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
			con = DriverManager.getConnection(
				"jdbc:odbc:MySQL"
				+";user=root"
				+";password="
				+";server=localhost"
				+";database=lightbox"
			);
			stmt = con.createStatement();

			rset = stmt.executeQuery ( "select * from `社員マスタ`" );

			ResultSetMetaData rm = rset.getMetaData();
			int nCols = rm.getColumnCount();
			String[] data = new String[nCols];
			int i;

			while( rset.next() ) {
				System.out.print( rset.getString( "氏名" ) + ":" );
				for( i = 0; i < nCols; i++ ) {
					data[i] = rset.getString( i+1 );

					if ( i != 0 ) {
						System.out.print( "," );
					}
					System.out.print( data[i] );
				}
				System.out.println(  );
			}

			stmt.close();
			con.close();

		}
		catch (Exception e) {
			System.out.println( e.getMessage() );
		}

	}
}
  

  Oracle10g : java ( ojdbc14.jar )

  

import java.sql.*;
import oracle.jdbc.pool.OracleDataSource;

public class oracle10g {

	public static void main(String[] args) {

		Connection con;
		Statement stmt;
		ResultSet rset;

// *********************************************************
// ojdbc14.jar
// Classes for use with JDK 1.4 and 5.0.  It contains the JDBC driver
// classes, except classes for NLS support in Oracle Object and
// Collection types.
// *********************************************************
		try {
			OracleDataSource ods = new OracleDataSource();
			ods.setUser("lightbox");
			ods.setPassword("lightbox");
			ods.setURL("jdbc:oracle:oci:@//localhost/XE");
			con = ods.getConnection();

			stmt = con.createStatement();

			rset = stmt.executeQuery ( "select * from 社員マスタ" );

			ResultSetMetaData rm = rset.getMetaData();
			int nCols = rm.getColumnCount();
			String[] data = new String[nCols];
			int i;

			while( rset.next() ) {
				System.out.print( rset.getString( "氏名" ) + ":" );
				for( i = 0; i < nCols; i++ ) {
					data[i] = rset.getString( i+1 );

					if ( i != 0 ) {
						System.out.print( "," );
					}
					System.out.print( data[i] );
				}
				System.out.println(  );
			}

			stmt.close();
			con.close();

		}
		catch (Exception e) {
			System.out.println( e.getMessage() );
		}

	}
}
  

  MySQL : PHP ( MySQL 関数 )

  

$Server = $Server == '' ? 'localhost' : $Server;
$DbName = $DbName == '' ? 'lightbox' : $DbName;
$User = $User == '' ? 'root' : $User;

$this->Connect = @mysql_connect( $Server, $User, $Password );
if ( !$this->Connect ) {
	$this->Error = "version --> " . phpversion() . "<br />";
	$this->Error .= "<b>dbmysql_connect</b><br />";
	$this->Error .= __FILE__ . "<br />";
	$this->Error .= "FUNCTION -->" . __FUNCTION__ . "<br />";
	$this->Error .= "CLASS --> " .__CLASS__ . "<br />";
	if ( substr( phpversion(), 0, 1 )+0 > 4 ) {
		$this->Error .= "METHOD --> " . __METHOD__ . "<br />";
	}
	else {
		$this->Error .= "METHOD --> ? : use php5<br />";
	}
	return;
}
mysql_select_db( $DbName, $this->Connect );
if ( $GLOBALS['conf_db_connect_action'] != '' ) {
	mysql_query( $GLOBALS['conf_db_connect_action'], $this->Connect );
}
  

  SQLServer : PHP ( Microsoft SQL Server 関数 )

  

$Server = $Server == '' ? '127.0.0.1' : $Server;
$DbName = $DbName == '' ? 'lightbox' : $DbName;
$User = $User == '' ? 'sa' : $User;

if ( !extension_loaded( "mssql" ) ) {
	dl("php_mssql.dll");
}
$this->Connect = mssql_connect( $Server, $User, $Password );
mssql_select_db( $DbName, $this->Connect );
if ( $GLOBALS['conf_db_connect_action'] != '' ) {
	 mssql_query( $GLOBALS['conf_db_connect_action'], $this->Connect );
}
  

  PostgreSQL : PHP ( PostgreSQL 関数 )

  

$Server = $Server == '' ? 'localhost' : $Server;
$DbName = $DbName == '' ? 'lightbox' : $DbName;
$User = $User == '' ? 'lightbox' : $User;

if ( !extension_loaded( "pgsql" ) ) {
	dl("php_pgsql.dll");
}
$this->Connect = pg_connect(
	"host=$Server" .
	" port=5432" .
	" dbname=$DbName" .
	" user=$User" .
	" password=$Password"
);
if ( $GLOBALS['conf_db_connect_action'] != '' ) {
	pg_query( $this->Connect, $GLOBALS['conf_db_connect_action'] );
}
  

  MDB : PHP ( COM + ADO )

  

$this->Cn = new COM( "ADODB.Connection" );
$this->Cn->CursorLocation = 3;
$this->Rs = new COM( "ADODB.Recordset" );

$Server = $Server == '' ? realpath( "hanbaib.mdb" ) : $Server;
$ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;";
$ConnectionString .= "Data Source=$Server;";

$this->Cn->Open( $ConnectionString );
if ( $GLOBALS['conf_db_connect_action'] != '' ) {
	$this->Cn->Execute( $GLOBALS['conf_db_connect_action'] );
}
  

  Oracle : PHP ( COM + ADO )

  

$this->Cn = new COM( "ADODB.Connection" );
$this->Cn->CursorLocation = 3;
$this->Rs = new COM( "ADODB.Recordset" );

$ConnectionString = "Provider=MSDASQL;";
$ConnectionString .= "DSN=$Server;";
$ConnectionString .= "UID=$User;";
$ConnectionString .= "PWD=$Password;";

$this->Cn->Open( $ConnectionString );
if ( $GLOBALS['conf_db_connect_action'] != '' ) {
	$this->Cn->Execute( $GLOBALS['conf_db_connect_action'] );
}
  

  Oracle : PHP( COM + OO4O )

  

$this->Oracle = new COM( "OracleInProcServer.XOraSession" );
$this->Cn = $this->Oracle->OpenDatabase($Server, "$User/$Password", 0);

if ( $GLOBALS['conf_db_connect_action'] != '' ) {
	$this->Cn->ExecuteSQL( $GLOBALS['conf_db_connect_action'] );
}
  

  MDB : PHP ( Unified ODBC 関数 )

  

<?
# **********************************************************
# データベースクラス
# **********************************************************
class DB {
 
	var $Connect;
	var $Result;
 
# **********************************************************
# コンストラクタ
# **********************************************************
	function DB( $Dsn='MDB' ) {
		$this->Connect = odbc_connect( $Dsn, '', '' );
	}
 
# **********************************************************
# 接続解除
# **********************************************************
	function Close( ) {
		odbc_close( $this->Connect );
	}
 
# **********************************************************
# クエリー
# **********************************************************
	function Query( $SqlQuery ) {
		$ret = odbc_exec( $this->Connect, $SqlQuery );
		return $ret;
	}
 
# **********************************************************
# フェッチ
# **********************************************************
	function Fetch( $Result ) {
		return odbc_fetch_array( $Result );
	}
 
# **********************************************************
# クエリーとフェッチ
# **********************************************************
	function QueryEx( $SqlQuery='' ) {
 
		if ( $SqlQuery != '' ) {
			$this->Result = $this->Query( $SqlQuery );
			if ( !$this->Result ) {
				return FALSE;
			}
			return $this->Fetch ( $this->Result );
		}
		else {
			return $this->Fetch ( $this->Result );
		}
 
	}
 
# **********************************************************
# 実行
# **********************************************************
	function Execute( $SqlExec ) {
		$ret = odbc_exec( $this->Connect, $SqlExec );
		return $ret;
	}
 
# **********************************************************
# エラーメッセージ取得
# **********************************************************
	function GetError() {
		return odbc_errormsg( $this->Connect );
	}
 
}
?>
  

  Excel : VBScript

  

strTarget = "C:\TEMP\excel\Book1.xls"

ConnectionString = _
	"Provider=Microsoft.Jet.OLEDB.4.0;" & _
	"Data Source=" & strTarget & ";" & _
	"Extended Properties=""Excel 8.0;IMEX=1;"""

on error resume next
Cn.Open ConnectionString
if Err.Number <> 0 then
	WScript.Echo Err.Description
	Wscript.Quit
end if
on error goto 0

' 処理

Cn.Close
  

  MDB : VBScript

  

strTarget = "C:\TEMP\MDB\販売管理B.mdb"

ConnectionString = _
	"Provider=Microsoft.Jet.OLEDB.4.0;" & _
	"Data Source=" & strTarget & ";"

on error resume next
Cn.Open ConnectionString
if Err.Number <> 0 then
	WScript.Echo Err.Description
	Wscript.Quit
end if
on error goto 0

' 処理

Cn.Close
  

  SQLServer : VBScript

  

strServer = "sv"
strInstance = "MSDE2000"
strTarget = strServer & "\" & strInstance
strDB = "lightbox"
strUser = "sa"
strPass = "password"

ConnectionString = _
	"Provider=SQLOLEDB;" & _
	"Data Source=" & strTarget & ";" & _
	"Initial Catalog=" & strDB & ";" & _
	"User ID=" & strUser & ";" & _
	"Password=" & strPass & ";"

on error resume next
Cn.Open ConnectionString
if Err.Number <> 0 then
	WScript.Echo Err.Description
	Wscript.Quit
end if
on error goto 0

' 処理

Cn.Close
  

  MySQL : VBScript( ODBC )

Oracle や PostgreSQL はこの方法で接続します

DSN が定義されている場合
  

strTarget = "MySQL"
strDB = "lightbox"
strUser = "root"
strPass = ""

ConnectionString = _
	"Provider=MSDASQL" & _
	";DSN=" & strTarget & _
	";DATABASE=" & strDB & _
	";UID=" & strUser & _ 
	";PWD=" & strPass & _ 
	";" 

on error resume next
Cn.Open ConnectionString
if Err.Number <> 0 then
	WScript.Echo Err.Description
	Wscript.Quit
end if
on error goto 0

' 処理

Cn.Close
  

DSN が定義されていない場合
  

strDriver = "{MySQL ODBC 3.51 Driver}"
strServer = "localhost"
strDB = "lightbox"
strUser = "root"
strPass = ""

ConnectionString = _
	"Provider=MSDASQL" & _
	";Driver=" & strDriver & _
	";Server=" & strServer & _
	";DATABASE=" & strDB & _
	";UID=" & strUser & _ 
	";PWD=" & strPass & _ 
	";" 

on error resume next
Cn.Open ConnectionString
if Err.Number <> 0 then
	WScript.Echo Err.Description
	Wscript.Quit
end if
on error goto 0

' 処理

Cn.Close
  

  Oracle : VBScript ( OO4O + DatabasePool )

  

' **********************************************************
' オブジェクト作成
' **********************************************************
Set OraSession = CreateObject( "OracleInProcServer.XOraSession" )
Set Fs = CreateObject( "Scripting.FileSystemObject" )

' **********************************************************
' 接続
' **********************************************************
on error resume next
OraSession.CreateDatabasePool 1,40,200,"lightbox", "lightbox/lightbox", 0
if Err.Number <> 0 then
	Wscript.Echo OraSession.LastServerErrText
	Wscript.Quit
end if
on error goto 0
Set OraDatabase	= OraSession.GetDatabaseFromPool(10)
OraDatabase.LastServerErrReset

' **********************************************************
' レコードセット取得
' **********************************************************
Query = "select * from 社員マスタ"
on error resume next
Set OraDynaset = OraDatabase.CreateDynaset(Query,2)
if Err.Number <> 0 then
	Wscript.Echo OraDatabase.LastServerErrText
	Wscript.Quit
end if
on error goto 0

' **********************************************************
' 出力ファイルオープン
' **********************************************************
Set Csv = Fs.CreateTextFile( "社員マスタ.csv", True )

' **********************************************************
' タイトル出力
' **********************************************************
Buffer = ""
For i = 0 to OraDynaset.Fields.Count - 1
	if Buffer <> "" then
		Buffer = Buffer & ","
	end if
	Buffer = Buffer & OraDynaset.Fields(i).Name
Next
Csv.WriteLine Buffer

' **********************************************************
' データ出力
' **********************************************************
Do While not OraDynaset.EOF
	Buffer = ""
	For i = 0 to OraDynaset.Fields.Count - 1
		if Buffer <> "" then
			Buffer = Buffer & ","
		end if
		Buffer = Buffer & OraDynaset.Fields(i).Value
	Next
	Csv.WriteLine Buffer
	OraDynaset.MoveNext
Loop

' **********************************************************
' ファイルクローズ
' **********************************************************
Csv.Close

' **********************************************************
' オブジェクト解放
' **********************************************************
Set Fs = Nothing
Set OraDynaset = Nothing
Set OraDatabase = Nothing
Set OraSession = Nothing
  


ASP による GLOBAL.ASA 利用
  

<OBJECT 
	runat=Server
	scope=Application
	id=OraSession
	progid="OracleInProcServer.XOraSession"
></OBJECT>
<SCRIPT language=VBScript runat=Server> 

' **********************************************************
' アプリケーション開始
' **********************************************************
Sub Application_OnStart

	OraSession.CreateDatabasePool 1,40,200,"LIGHTBOX","STUDY/STUDY", 0

End Sub

' **********************************************************
' アプリケーション終了
' **********************************************************
Sub Application_OnEnd


End Sub

' **********************************************************
' セッション開始
' **********************************************************
Sub Session_OnStart


End Sub

' **********************************************************
' セッション終了
' **********************************************************
Sub Session_OnEnd


End Sub

</SCRIPT>
  




yahoo  google  MSDN  MSDN(us)  WinFAQ  Win Howto  tohoho  ie_DHTML  vector  wdic  辞書  天気 


[dbaccess]
CCBot/2.0 (https://commoncrawl.org/faq/)
24/12/09 07:15:22
InfoBoard Version 1.00 : Language=Perl

1 BatchHelper COMprog CommonSpec Cprog CprogBase CprogSAMPLE CprogSTD CprogSTD2 CprogWinsock Cygwin GameScript HTML HTMLcss InstallShield InstallShieldFunc JScript JScriptSAMPLE Jsfuncs LLINK OldProg OracleGold OracleSilver PRO PRObrowser PROc PROconePOINT PROcontrol PROftpclient PROjscript PROmailer PROperl PROperlCHAT PROphp PROphpLesson PROphpLesson2 PROphpLesson3 PROphpfunction PROphpfunctionArray PROphpfunctionMisc PROphpfunctionString PROsql PROvb PROvbFunction PROvbString PROvbdbmtn PROvbonepoint PROwebapp PROwin1POINT PROwinSYSTEM PROwinYOROZU PROwindows ProjectBoard RealPHP ScriptAPP ScriptMaster VBRealtime Vsfuncs a1root access accreq adsi ajax amazon argus asp aspSample aspVarious aspdotnet aw2kinst cappvariety centura ckeyword classStyle cmaterial cmbin cmdbapp cmenum cmlang cmlistbox cmstd cmstdseed cmtxt cs daz3d db dbCommon dbaccess dnettool dos download flex2 flex3 flex4 framemtn framereq freeWorld freesoft gimp ginpro giodownload google hdml home hta htmlDom ie9svg install java javaSwing javascript jetsql jquery jsp jspTest jspVarious lightbox listasp listmsapi listmsie listmsiis listmsnt listmspatch listmsscript listmsvb listmsvc memo ms msde mysql netbeans oraPlsql oracle oracleWiper oraclehelper orafunc other panoramio pear perl personal pgdojo pgdojo_cal pgdojo_holiday pgdojo_idx pgdojo_ref pgdojo_req php phpVarious phpguide plsql postgres ps r205 realC realwebapp regex rgaki ruby rule sboard sc scprint scquest sdb sdbquest seesaa setup sh_Imagick sh_canvas sh_dotnet sh_google sh_tool sh_web shadowbox shgm shjquery shvbs shweb sjscript skadai skywalker smalltech sperl sqlq src systemdoc tcpip tegaki three toolbox twitter typeface usb useXML vb vbdb vbsfunc vbsguide vbsrc vpc wcsignup webanymind webappgen webclass webparts webtool webwsh win8 winofsql wmi work wp youtube