Friday, March 23, 2012

Problem in accessing the database.. please help!

Hi There !!

CAn you please help me to solve my probelm and i will appreciate it if you help me. I installed SQL server on my machine and i installed tables in a database called "otters" when i run the application, i got an error message on the browser as shown below although in the application it says that it recognise the source of the dastabase. CAn you please help me to sort out tis problem and please try to look back to this thread after givingf me the soultion as it might not work and i need more assistant. I really, appreciate your help and thank you in advance. Please read the error message below
**************************************************

Server Error in '/Otters' Application.
------------------------

SQL Server does not exist or access denied.
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: SQL Server does not exist or access denied.

Source Error:

Line 403: Dim conn As New SqlConnection(connStr)
Line 404: cmd.Connection = conn
Line 405: conn.Open()
Line 406:
Line 407: ' Allocate an empty array list to hold the performance objects found

Source File: C:\CSE506\Theater\Performance.vb Line: 405

Stack Trace:

[SqlException: SQL Server does not exist or access denied.]
System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction)
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction)
System.Data.SqlClient.SqlConnection.Open()
Theater.Performance.Find(SqlCommand cmd) in C:\CSE506\Theater\Performance.vb:405
Theater.Performance.FindByDateRange(DateTime st, DateTime et) in C:\CSE506\Theater\Performance.vb:369
Otters.admin.Page_Load(Object sender, EventArgs e) in C:\Inetpub\wwwroot\Otters\secure\admin.aspx.vb:67
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731

------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET

------------------------Show your connection string. Are you using integrated security?|||Hi Sir !!

Thank you for your message. T o be honest with you, I do not know how can i show the connection string or where would i find it and i do not know about the integrated security?....... :( i am very soooorry

I wish you can help me. I have a code that need to build a data base. I did install SQL Server and the database with all tables. when i run the application as you can see i had the error message. I wish if you can help me.

The material in the application is very important to me run as i am new in web development and .NET Framework. I am really grateful and will be more grateful if you can help as much as you can to sort this problem out.|||In this code:

Dim conn As New SqlConnection(connStr)

The string connStr is what you need to show (if there are usernames and passwords, just change them to USER and PASSWORD).|||Hi Mr Douglas.reilly !!

This is the code below, it does not have a password or user name. Can you please advice what to do. Thank you again and i look froward to hearing from you.

****************** Code ***********************************
' Write a new customer object out to the primary database, retrieving the
' newly allocated identity field. Should only be called from inside a
' constructor.

Private Function Insert() As Integer

' Copy the customer out to the table of customers.

Dim conn As New SqlConnection(connStr)
Dim cmd As New SqlCommand("INSERT INTO Customers (Name, Address, " _
& "Email) VALUES ( @.nm, @.ad, @.em);" _
& "SELECT ID FROM Customers WHERE (ID = SCOPE_IDENTITY())", conn)
cmd.Parameters.Add("@.nm", custName)
cmd.Parameters.Add("@.ad", custAddress)
cmd.Parameters.Add("@.em", custEmail)

' Now execute the insertion onto the primary table

conn.Open()
Dim identity As Integer = CType(cmd.ExecuteScalar(), Integer)
conn.Close()
Return identity

End Function|||SOMEPLACE in the code, connStr is set. Find out where it is. Or, if you are not using OPTION EXPLICIT, perhaps it is not ever set, and that would also explain the problem. In your code, connStr MUST be a valid connection string, as specified in the link I have previously posted. If you do not know what must be in that string, it is not really something anyone else can help with.|||Hi Mr Douglas!!

Thank you again for your message. I searched the whole file and i could not find it. It is very disappointed for me that you can help. I can attached the application with the datadase .sql files to see yourself and if you do not mind i can email it to you. I wish you will be able to help it is very important to me and please, do not let me down. I wish i do not embaress you or ask you for what you can not do.

I wish you will able to help and anything i will do to sort this problem out.|||Do a control-F and search for 'connStr'

if you can't find a place where it specifically assigns a connection string (the way your script 'connects' to the database), then it won't work any way - - you must connect to the database, in order to display or edit data.
it will look like:
connStr = "...your connection 'string' will be here..."

No comments:

Post a Comment