Login failed
jeg prøver at forbinde til northwind databasen, men jeg får denne fejl:Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.
hvad gør jeg forkert ????
kode:
<%@Page Language="c#"%>
<%@Import Namespace="System.Data" %>
<%@Import Namespace="System.Data.SqlClient" %>
<html>
<head>
<title> WROX Beginning ASP.NET - Data - Data Table <br/>
Using Microsoft SQL Objects</title>
</head>
<body>
<h2>Display of Data in a Table (Grid) Using SQL Objects</h2>
Northwind Employees:<hr/>
<asp:datagrid id="dgrEmployees" runat="server" />
<script Language="c#" runat="server">
void Page_Load()
{
// First we will set up variables to hold two strings
string strSQL = "SELECT FirstName,LastName FROM Employees;";
string strConnection = "server=(local); ";
strConnection += "database=Northwind;uid=sa;password=dbo;";
DataSet objDataSet = new DataSet();
SqlConnection objConnection = new SqlConnection(strConnection);
// Create a new DataAdapter using the connection object and select statement
SqlDataAdapter objDataAdapter = new SqlDataAdapter(strSQL, objConnection);
// Fill the dataset with data from the DataAdapter object
objDataAdapter.Fill(objDataSet, "Employees");
// Create a DataView object for the Employees table in the DataSet
DataView objDataView = new DataView(objDataSet.Tables["Employees"]);
// Assign the DataView object to the DataGrid control
dgrEmployees.DataSource = objDataView;
dgrEmployees.DataBind(); // and bind [display] the data;
}
</script>
</body>
</html>
