I'm new...
I've installed Web Matrix, and MDSE. I've been successful in installing the Time Tracker Starter kit, I've connected to multiple databases (SQL and Access) within Web Matrix and I'm now trying to connect to my own SQL database...with limited success.
Scenario:
I've created a SQL database using MS Access (*.adp) access project for SQL. I've created a new ASPX with Web Matrix and placed a database table into my new ASPX by draggin-n-droppin the table from the DATA connections in Web Matrix. Everything goes smoothly...
When I view the page using the Web Matrix 'built-in' web server (i.e. http://localhost:8080/default.aspx), everything displays just fine...it appears that the script is connecting properly to the database and executing the query without any problem -- I can view my data within the page. However, when I view this page using IIS (i.e. http://localhost/default.aspx), I get:
System.Data.SqlClient.SqlException: Cannot open database requested in login 'myDB'. Login fails. Login failed for user 'MYCOMPUTER\ASPNET' and then a stack dump.
Same code...different web servers...different results.
I've checked as many SQL permissions as I could think of, but my experience with SQL is limited. I'm using Microsoft's FREE SQL tools, but I'm pretty certain that there should be a simple way to ensure that my ASPNET user account has appropriate permissions to access my SQL database through IIS.
any suggestions?As you can see the sql error is occuring as the ASPNET account on your machine doesn't have sql priveleges - to solve this you could either add the apsnet account to sql logins and give it sufficient permissions or impersonate and identity which has sufficient sql priveleges.
Hope that helps
Kashif|||I have the same problem .
Would you please tell me how to add the apsnet account to sql logins .|||You can either run the following stored procedure to add the aspnet account
sp_grantlogin @.loginamein your case @.login name would be "MachineName\ASPNET" or if you have SQL Enterprise Manager you can open the sql server you want to add the login to and then select security -> Logins -> NewLogin
Hope that helps
Kashif|||Thank you so much. However, I do have MSDE on my Windows XP machine.
and stil have the same problem.
your help will be appreciated.|||To installed MSDE on your system with SQL authentication support use this command:
Setup SAPWD=(Some password) SecurityMode=SQL
where setup is the executable of the setup of MSDE (download it over here with SP3 integrated:http://www.asp.net/msde/default.aspx?tabindex=0&tabid=1). Follow the instructions of the setup.
When you've done so, you can login to the MSDE database using this credentials:
uid=sa
pwd=(Some password)
Replace the (Some password) in the command line by the password you like.|||Thank you so much for your response however I already done that but it doesn't work:
This is my frist samle project for MSDE so would tell me the steps:
1. Create a project by MS Access and login='sa' password='passowrd'. that mean the SQL server is running and it's shown at my desck top.
2. write a small ample of aspx code by WebMatrix
3, it gives me the "Cannot open database requested in login 'adp1'. Login fails. Login failed for user 'sa'."
<%@. Page Language="C#" %>|||From the error it seems the password you are using for sa is incorrect, can you try running some sql scripts from command line using login sa and password password and see if you are able to run those.
<%@. import Namespace="System.Data" %>
<%@. import Namespace="System.Data.OleDb" %>
<%@. import Namespace="System.Data.SqlClient" %>
<script runat="server"
void Page_Load(object sender, EventArgs e) {// TODO: Update the ConnectionString and CommandText values for your application
string ConnectionString = "server=(local);database='adp1';uid='sa'; pwd='password'";
string CommandText = "select * from news";SqlConnection myConnection = new SqlConnection(ConnectionString);
SqlDataAdapter objCmd1 = new SqlDataAdapter( CommandText, myConnection);
DataSet ds1 = new DataSet();
objCmd1.Fill(ds1);//myDataList1.DataSource = ds1;
//MyDataList1.DataBind();
}</script>
<html>
<head>
</head>
<body style="FONT-FAMILY: arial">
<h2>Simple Data Report
</h2>
<hr size="1" />
<ASP:DataList id="MyDataList1" RepeatColumns="1" RepeatDirection="Horizontal" runat="server">
<ItemTemplate>
<table border="0" cellpadding="2" width="100%" height="68">
<tr valign="TOP">
<td width="20%" valign="top" rowspan="2" height="62">
Hello
</td>
<td width="80%" valign="top" height="7">
<font face="Verdana" size="2"> <%# DataBinder.Eval(Container.DataItem, "news_title") %> <font face="Verdana" size="1.5"><%# DataBinder.Eval(Container.DataItem, "news_date") %> </font> </font></td>
</tr>
<tr>
<td width="70%" valign="top" height="49">
<font face="Verdana" size="1.5"> <%# DataBinder.Eval(Container.DataItem, "news_description") %> </font>
</td>
</tr>
</table>
</ItemTemplate>
</ASP:DataList>
</body>
</html>
-Kashif|||thank you so muh, I am sorry but I been away for a short vacation.
This is my frist samle project for MSDE so would tell me the steps.
I do not have SQL Server..
Would you tell me how to check these command. ...
sat|||Open command prompt, switch to binn directory msde and run something like the following
osql -U sa id -P myPwd -S (.) -d Northwind -q "Select * from customers"if this fails to run then we know that you are either not setting the sa password right or the MSSQL service is not running on your machine. Also if you have a named instance of MSDE installed then you would use "-S ServerName\InstanceName"
Hope that helps
Kashif|||Thank you.
I have created MS Acces project called adp1. wehn I open the project it asks me for user "sa" and password. I have database tables "news". however when I write the following:
>osql -U sa -P password -S (.) -D adp1 -Q "Select * from news"
Error " Data Source name not found and no default driver"
>osql -U sa -P password -S localhost\adp1 -D adp1 -Q "Select * from news"
Error " Data Source name not found and no default driver"|||actullay, after I run the previous command I got this error on my
http://localhost/
403 Forbidden - The server denies the specified Uniform Resource Locator (URL). Contact the server administrator. (12202)
Internet Security and Acceleration Server.
any explations please..!!! thank you|||The error you have specified above just implies that there is no page defined. Can you look up the Default wesite's home directory and see the "Default document" tab.
-Kashif|||Hello all,
I am writing this message simply because I started this thread and I wanted to remark that with ALL your help, and with many hours of studying SQL server permissions, osql commands and syntax, SQL server port configuration and firewalls, I have resolved the problems I was having when I started this thread.
Thanks to all who provided excellent advice and tolerated my previous ignorances.
Regards.
No comments:
Post a Comment