Populate DataGrid in C# WebForm from SQL Localhost

  • Thread starter Thread starter Calvin Willman
  • Start date Start date
C

Calvin Willman

Hi All,

I am trying to populate a DataGrid on a C# Web Form,
using VS.NET from data stored on my local machine, but
keep getting unhandled exception, Server doesn't exist or
access denied. It's the MSDE.

Thought if I got a copy of Enterprise Manager, I could
create a login specific for this purpose, so downloaded
the 120-Day trial for the client tools, created a logon,
etc.

However, I have just got the same problem. It works
however if I choose to populate the DataGrid from the
remote SQL Server at my Hosting Company, so I'm tearing
my hair out.

Is it the connection string I'm using in the
SqlConnection object? Read some other posts on here,
something about changing LoginMode in Registry Editor to
0, but couldn't find it. Can anyone help, please... I'm
losing sleep... :O)

Calvin
 
Can you post the block where the exception is being thrown, and ideally the
line that's giving you the problem?
 
/// It's when creating the SqlConnection object...
Changed the LoginMode in Regedit to 0 as per another
post, but now get login failed for user exception.



public class WebForm1 : System.Web.UI.Page
{
protected
System.Web.UI.WebControls.DataGrid DataGrid1;

private void Page_Load(object sender,
System.EventArgs e)
{
SqlConnection cnCust = new
SqlConnection("integrated security=sspi; Initial
Catalog=master;Data Source=(local)");

SqlDataAdapter daCust = new
SqlDataAdapter("select ProductID, ProductName FROM
Products", cnCust);

DataSet dsCust = new DataSet();
daCust.Fill(dsCust, "Products");

DataGrid1.DataSource =
dsCust.Tables["Products"].DefaultView;
DataGrid1.DataBind();
}
 
Back
Top