Join Access
See segment of an example code above all:
Program code:
——————————————————————————–Using System.Data;Using System.Data.OleDb;
. . . . . .
String StrConnection= “Provider=Microsoft.Jet.OleDb.4.0;” ;StrConnection =@ “Data Source=C:\BegASPNET\Northwind.mdb” ;
OleDbConnection ObjConnection=new OleDbConnection(strConnection);
. . . . . .
ObjConnection.Open();ObjConnection.Close();
. . . . . .
——————————————————————————–
Explanation:
Join Access database needs to guide name a space additionally, had two Using of foremost face to command so, this is indispensable!
What StrConnection deposits in this variable is the join string that join database needs, the person that he appointed the data that should use to offer and the data source that should use.
“Provider=Microsoft.Jet.OleDb.4.0;” is the person that show data is offerred, what use here is Microsoft Jet engine, namely the data engine in Access, asp.net relies on this database connective with Access namely.
“Data Source=C:\BegASPNET\Northwind.mdb” is the position of demonstrate data source, his standard form is “Data Source=MyDrive:MYPath\MyFile.MDB” .
Ps:
1. ” the “@” symbol at the back of =” is to prevent will from the back the “\” in string is analytic for escape character.
2. If want connective database file and current file to be in same below catalog, return the methodological connection that can use as follows:
StrConnection = “Data Source=” ;
StrConnection =MapPath(”Northwind.mdb” );
Such OK you write so as to save one pile thing!
3. Space should come with semicolon between the parameter in wanting to notice join string.
“OleDbConnection ObjConnection=new OleDbConnection(strConnection);” is this one to use the join string that has defined to established target of a link, the operation that logarithm occupies a library after we want and this object contact with.
“This uses ObjConnection.Open();” to open join. So far, finish with the join of Access database. The others is operated (insert, delete. . . ) consult please relevant book
Join SQL Server
Exemple filial generation piles up a segment:
Program code:
——————————————————————————–Using System.Data;Using System.Data.SqlClient;
. . .
String StrConnection= “user Id=sa;password=;” ;StrConnection = “initial Catalog=Northwind;Server=YourSQLServer;” ;StrConnection = “Connect Timeout=30″ ;
SqlConnection ObjConnection=new SqlConnection(strConnection);
. . .
ObjConnection.Open();ObjConnection.Close();
. . .
——————————————————————————–
In all 2 pages: On one page 1[2] Issue one page
