C#.NET - Jobba med databaser
Anslut till MySQL-databas
Spar exempelkoden nedan i en fil med filändelsen .aspx
Exempelkod:
<%@ Page Language="C#" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Odbc" %>
<html>
<head>
<title>MySQL connect - C#.NET</title>
</head>
<body>
<%
OdbcConnection myConnection;
myConnection = new OdbcConnection(@"Driver={MySQL ODBC 5.2 ANSI Driver};Server=localhost;Database=db_name;User=root;Password=password_for_user_root;Socket=MySQL;Option=3;");
myConnection.Open();
Response.Write("Connected to database");
myConnection.Close();
%>
</body>
</html>


