Searchable form in /getting an error while accessing the database- Urgent please help

Posted on 2006-04-20
Last Modified: 2012-05-05
Private Sub btnsearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsearch.Click
        Dim dr As SqlClient.SqlDataReader
        Dim objConnection As New SqlClient.SqlConnection
        Dim objCommand As New SqlClient.SqlCommand
        Dim objAdapter As New SqlClient.SqlDataAdapter
        Dim objDataSet As New DataSet
        Dim strSearch As String
        Dim strSQLQuery As String
        ' Get Search
        If Page.IsValid Then
            strSearch = txtFname.Text
                    ' If there's nothing to search for then don't search
                    ' o/w build our SQL Query and execute it.
                    If Len(Trim(strSearch)) > 0 Then
                        ' Set up our connection.
                objConnection = New SqlClient.SqlConnection("Data Source=daisql;" _
                         & "Initial Catalog=KSBOA_DATA;User Id=guest000;Password=guest000;")

                        ' Set up our SQL query text.
                        strSQLQuery = "SELECT firstname,lastname, city, state " _
                         & "FROM tblboadata " _
                         & "WHERE lastname LIKE '%" & Replace(strSearch, "'", "''") & "%' " _
                        & "OR firstname LIKE '%" & Replace(strSearch, "'", "''") & "%' " _
                         & "ORDER BY lastname;"

                        ' Create new command object passing it our SQL query
                        ' and telling it which connection to use.
                        objCommand = New SqlClient.SqlCommand(strSQLQuery, objConnection)

                        ' Get a DataSet to bind the DataGrid to
                        objAdapter = New SqlClient.SqlDataAdapter(objCommand)
                        objDataSet = New DataSet

                        ' DataBind DG to DS
                        dgIndividual.DataSource = objDataSet.DefaultViewManager

                        TxtLName.Enabled = False
                        txtFname.Text = "Enter Search Here"
                    End If
        End If
    End Sub

Error received:

Line 90:                         objAdapter = New SqlClient.SqlDataAdapter(objCommand)
Line 91:                         objDataSet = New DataSet
Line 92:                         objAdapter.Fill(objDataSet)
Line 93:
Line 94:                         ' DataBind DG to DS

Source File: c:\inetpub\wwwroot\BOASearch\Search for Individual.aspx.vb    Line: 92

Stack Trace:

[SqlException: SQL Server does not exist or access denied.]
   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
   BOASearch.IndividualSearch.btnsearch_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\BOASearch\Search for Individual.aspx.vb:92
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain() +1292

Question by:amruthanet
    LVL 23

    Expert Comment

    Do you have a firewall on the server? Check if port 1433 is bieng blocked by it. If it is, then you need to open that port to allow access to SQL server.

    Author Comment

    Thanks.  The port number is 2433.  How can I open the port?

    Please let me know.
    LVL 23

    Accepted Solution

    What kind of firewall is it? Is it the one that comes with XP - SP2?

    Author Comment

    I found the problem. I have misspelled the datasource name.

    Thanks for your help.
    LVL 23

    Expert Comment

    Post a comment in admin area to delete this question.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
    ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now