Solved

need help in connecting to sql server.

Posted on 2014-09-04
5
176 Views
Last Modified: 2014-09-09
trying to connect to a local sql server.  Services are running, name is correct, allow remote connection is on.  Tried multiple connection strings, none worked.  Attached is the error and a picture of screen.

<script language="VB" runat="server">
    Sub Page_load(Source As Object, E As EventArgs)  Handles Me.Load
        Dim strConnection As String = "server=WPC213\NetSDK;database=CUDATA; integrated security=True;"
        'Dim strConnection As String = "server=WPC213;database=CUDATA; integrated security=True;"
        'Dim strConnection As String = "server=Local;database=CUDATA; integrated security=True;"
        'Dim strConnection As String = "server=cudata; integrated security=True;"
        'Dim strConnection As String = "Data Source=local; database=cudata; integrated security=true;Initial Catalog=wages1SQL;"
        Dim objConnection As New SqlConnection(strConnection)
        Dim strSQL As String = "Select EMPLOYEENAME, SOCSEC,BANKCODE,EMPLOYMENTDATE,TERMINATEDATE from EmployeeHireInfo"
        Dim objCommand As New SqlCommand(strSQL, objConnection)
        objConnection.Open()
        test.DataSource = objCommand.ExecuteReader()
        test.DataBind()
        objConnection.Close()
       
    End Sub
</script>
0
Comment
Question by:javagair
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 21

Accepted Solution

by:
Randy Poole earned 250 total points
ID: 40304514
Dim strConnection As String = "Data Source=WPC213\NetSDK;Initial Catalog=CUDATA;Persist Security Info=True; integrated security=True"

Open in new window

If you are using TCP/IP instead of named pipes you may need to use:
Dim strConnection As String = "Data Source=WPC213\NetSDK,1433;Initial Catalog=CUDATA;Persist Security Info=True; integrated security=True"

Open in new window


BTW, you didn't include the an attached screen shot of the error.
0
 
LVL 33

Assisted Solution

by:Big Monty
Big Monty earned 250 total points
ID: 40305972
you can find the correct connection string at www.connectionstrings.com
0
 

Author Comment

by:javagair
ID: 40306137
the very first thing in the attached file is the error message.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 40307090
the very first thing in the attached file is the error message.
I think the hamsters ate your attached file.  Care to post it again?  Or even better still transcribe the error message in plain text.  You would be amazed how much simpler that can be.
0
 

Author Closing Comment

by:javagair
ID: 40313316
Dim strConnection As String = "Data Source=.\cudata;integrated security=true;Initial Catalog=wages1SQL;"

looked at answers, had a talk with myself, came up with the answer by interpolation of answers.

thanks
gair
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

733 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