VJCom - Your Computer Solution

Guides on setting up workgroup networks, Internet Connection Sharing, terminal server and much more. Our Troubleshooting guides will give you step by step instructions on fixing network and internet related problems

 
Calender With Clock


Sponsor Links
Click Adv
Get Paid With AWSurveys
Alert Pay The Way To Pay
Get Money With Adsensecamp
Adsense Indonesia
JMGOLD
Feedjit.com

Click here to get your free mobile phone or apple ipod

Programming - database connection scripts.
Thursday, June 19, 2008
Connections strings using various programming languages to different databases:
Note: watch for word wrap, some text may have moved to the next link
ASP to MSACCESS :
set conn = Server.CreateObject("ADODB.Connection")
conn.open "DRIVER={Microsoft Access Driver (*.mdb)}; " & "DBQ=" & Server.MapPath("access.mdb")
accessquery = "sql statement here"
set rs = conn.Execute(accessquery)
conn.close
set conn = nothing


ASP to Mysql :
set conn = Server.CreateObject("ADODB.Connection")
conn.open
"DRIVER={MySQL};SERVER=sqlservers;DATABASE=database_name;;UID=user_name;PWD=password"
sqlquery = "sql statement here"
set rs = conn.Execute(sqlquery)
set rs = conn.Execute(accessquery)
conn.close
set conn = nothing


PHP to mysql:
$conn = mysql_connect("sqlserver", "user", "temp123")
or die ("Could not connect");
print ("Connected successfully");
mysql_select_db ("database_name")
or die ("Could not select database");

$query = "sql statement here";
$result = mysql_query ($query)
or die ("Query failed");

mysql_close($conn);


ASP.NET (VB) to MSACCESS :
dim objConn as OleDbConnection
Sub Page_Load (obj as Object, e as EventArgs)
objConn = New OleDbConnection("Provider=Microsoft.Jet.oledb.4.0;Data Source=" & Server.MapPath("access.mdb"))
dim objCmd as OleDbcommand = new OleDbCommand("sql statement here", objConn)
Try
objCmd.Connection.Open()
objCmd.ExecuteNonQuery()
Catch ex as OleDbException
response.write("Error retrieving data")
Finally
objCmd.Connection.Close()
End Try
End Sub


ASP to MSSQL 2000 :
set conn = server.createobject("Adodb.connection")
conn.open Application("connectionString")
conn.open "Provider=SQLOLEDB;Data
Source=sqlservers;UID=username;pwd=temp12;database=database_name"
set rs=server.CreateObject("ADODB.RECORDSET"
rs.open "sql statement here", conn, 3 ,1
conn.close set conn = noth
set conn = nothing


ColdFusion to MySQL :
cfscript
driver="DRIVER={MySQL}";
server="SERVER=sqlservers";
database="DATABASE=database_name";
user="UID=user_name";
pass="PWD=temp123";
conn="#driver#;#server#;#database#;#user#;#pass#;option=16386";
/cfscript

cfquery DBTYPE="dynamic" CONNECTSTRING="#conn#" NAME="sql"
select statement here;
/cfquery


ASP.NET (c#) Mysql :
Private const string ConnStr = "Driver={MySQL ODBC 3.51Driver};" +"Server=sqlserver;Database=database_name;uid=user_name;pwd=temp123;option=3;
Protected override void OnInit(EventArgs e)
{
base.OnInit(e);
Using(OdbcConnection conn = new OdbcConnection(ConnStr))
Using(OdbcCommand cmd = new OdbcCommand("select satement here", conn))
{
conn.Open();
DS1.DataSource =cmd.ExecuteReader(CommandBehavior.CloseConnection CommandBehavior.SingleResult);
DS.DataBind();
}
}

posted by Boni Bona Ventura @ 6:27 PM  
0 Comments:
Post a Comment
<< Home
 






About Me

Name: Boni Bona Ventura
Home: Medan, Sumatera Utara, Indonesia
About Me:
See my complete profile
Previous Post
Archives
Links
Powered by

BLOGGER

Donate This Site
E-Gold
Amazon
© 2008 VJCom - Your Computer Solution