‎06-25-2015 02:13 AM
Solved! Go to Solution.
‎06-25-2015 03:18 PM
...
<%@ Import Namespace="System.Data.SqlClient" %>
...
string connectionString = null;
SqlConnection connection;
SqlCommand command;
string sql = null;
string result = null;
connectionString = @"Data Source=HOSTNAME\INSTANCENAME;" +
@"Initial Catalog=DATABASENAME;User ID=USERNAME;Password=PASSWORD";
sql = @"Your SQL query";
connection = new SqlConnection(connectionString);
try
{
connection.Open();
command = new SqlCommand(sql, connection);
result = command.ExecuteScalar().ToString();
command.Dispose();
connection.Close();
}
catch (Exception ex)
{
result = "No connection to Database";
}
%>
<p>The result is: <%:result%></p>
...
‎06-25-2015 03:18 PM
...
<%@ Import Namespace="System.Data.SqlClient" %>
...
string connectionString = null;
SqlConnection connection;
SqlCommand command;
string sql = null;
string result = null;
connectionString = @"Data Source=HOSTNAME\INSTANCENAME;" +
@"Initial Catalog=DATABASENAME;User ID=USERNAME;Password=PASSWORD";
sql = @"Your SQL query";
connection = new SqlConnection(connectionString);
try
{
connection.Open();
command = new SqlCommand(sql, connection);
result = command.ExecuteScalar().ToString();
command.Dispose();
connection.Close();
}
catch (Exception ex)
{
result = "No connection to Database";
}
%>
<p>The result is: <%:result%></p>
...
‎06-25-2015 03:23 AM
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now