Databases in sql

S

Shirley Flook

I am trying to learn C# and am getting totally lost. I am following through
the Microsoft 'Developing Web Applications' book, and have got to a bit
about Storing and Retrieving info with ADO.NET. (p.234 if anyone has this
book!).

I can connect to my training server to get the database up, and follow the
instructions to create a Dataset. Ithen have to put the following code in
the page_ load event:


//Fill the data set.
sqlAdapter1.Fill(DataSet1);
//Update the DataGrid.
dataGrid1.Databind();


When I run the application it always comes up in error. One error is that
the 'dataGrid' should have a capital D. Why when I have been told to type
it in as d?

Also I get this, which I can not make head nor tail of:



Server Error in '/mcsdwebapps/Chapter05/databases/AGAIN' Application.
--------------------------------------------------------------------------------

Login failed for user 'sa'.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Login failed for user
'sa'.

Source Error:


Line 30: {
Line 31: //Fill the data set.
Line 32: sqlDataAdapter1.Fill(DataSet1);
Line 33: //Update the DataGrid.
Line 34: dataGrid1.DataBind();


Source File:
c:\inetpub\wwwroot\mcsdwebapps\chapter05\databases\again\designmode.aspx.cs
Line: 32

Stack Trace:


[SqlException: Login failed for user 'sa'.]
System.Data.SqlClient.ConnectionPool.GetConnection(Boolean&
isInTransaction) +474
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString
options, Boolean& isInTransaction) +372
System.Data.SqlClient.SqlConnection.Open() +384
System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection,
ConnectionState& originalState) +44
System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +304
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord,
Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior
behavior) +77
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +38
AGAIN.WebForm1.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\mcsdwebapps\chapter05\databases\again\designmode.aspx.cs:32
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750



What does it mean? What am I doing wrong?

Iwould be really grateful if someone could help me please.

Thanks in anticipation
Shirley
 
W

W.G. Ryan MVP

The second error looks like the connection string is wrong -either the
username or password. Make sure your Sql Server is using Mixed mode
authentication (if you're using it like this) and that you have an sa
account and that the password in the connection string matches the real db
password.

Are you putting the code in the HTML page or the code ehind? THe ide should
stop you from making typos so I'm guessing it's in the html - if so, just
make sure that the name of the grid and the names you use to reference it
match in case. - I think it's a problem w/ casing.
Shirley Flook said:
I am trying to learn C# and am getting totally lost. I am following
through the Microsoft 'Developing Web Applications' book, and have got to a
bit about Storing and Retrieving info with ADO.NET. (p.234 if anyone has
this book!).

I can connect to my training server to get the database up, and follow the
instructions to create a Dataset. Ithen have to put the following code in
the page_ load event:


//Fill the data set.
sqlAdapter1.Fill(DataSet1);
//Update the DataGrid.
dataGrid1.Databind();


When I run the application it always comes up in error. One error is that
the 'dataGrid' should have a capital D. Why when I have been told to type
it in as d?

Also I get this, which I can not make head nor tail of:



Server Error in '/mcsdwebapps/Chapter05/databases/AGAIN' Application.
--------------------------------------------------------------------------------

Login failed for user 'sa'.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Login failed for
user 'sa'.

Source Error:


Line 30: {
Line 31: //Fill the data set.
Line 32: sqlDataAdapter1.Fill(DataSet1);
Line 33: //Update the DataGrid.
Line 34: dataGrid1.DataBind();


Source File:
c:\inetpub\wwwroot\mcsdwebapps\chapter05\databases\again\designmode.aspx.cs
Line: 32

Stack Trace:


[SqlException: Login failed for user 'sa'.]
System.Data.SqlClient.ConnectionPool.GetConnection(Boolean&
isInTransaction) +474

System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString
options, Boolean& isInTransaction) +372
System.Data.SqlClient.SqlConnection.Open() +384
System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection,
ConnectionState& originalState) +44
System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +304
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +77
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +38
AGAIN.WebForm1.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\mcsdwebapps\chapter05\databases\again\designmode.aspx.cs:32
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750



What does it mean? What am I doing wrong?

Iwould be really grateful if someone could help me please.

Thanks in anticipation
Shirley
 
S

Shirley

Thank you for your help. I have definately written the code in the code
behind and not the html. I have made sure all casings are the same, but
still do not get through.

I am learning this through a workplace and have to use their server for
which my tutor has given me the username and password, so I know that is
ok.

I have now got an error message saying about my 'Modifiers'.

I noticed when working through my book, that it says modifier- Family.
I could not change mine, and it came up automatically as 'Protected'.
The only chooses I have are public, protected, Protected Internal,
Internal, and Private.

What is a Modifier, and could this be the cause of my problem?

I thank you in anticipation for your help again. Does understanding
this get easier as you do more, cos it seems more like double dutch to
me at the moment?!!!

Thanks again.

Shirley.


Shirley
 
G

Guest

Please use the object name of the DataGrid1, if you have not chnaged it will
be DataGrid1 and in your page_load event you have not set the data source
property of your datagrid. according your code it seems it's a datagrid the
code should loook like

DataGrid1.DataSource = DataSet;

Raj
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top