vb.net reading SQL Server table error

Posted on 2003-02-25
Medium Priority
Last Modified: 2010-05-01
Basics:  VB.Net, Windows 2000, SQL Server 7.0

I am new to VB.net and am trying to do a simple read from the SQL Server table called pubs in the SQL Server Group called SV03.  However, I am getting the following error when I hit the following statement  "mSqlConnection.Open()" in my code.

"SQL Server does not exist or access denied."

Below is my code:

Imports System.Data.SqlClient

Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Private Sub cmdStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdStart.Click
        Dim mSqlConnection As New SqlConnection("initial catalog=SV03.pubs;data source=authors;")
        Dim mSqlCommand As New SqlCommand("Select * from Authors", mSqlConnection)
        Dim mDataReader As SqlDataReader

        End Try

        mDataReader = mSqlCommand.ExecuteReader
        MessageBox.Show("Name:  " & mDataReader("au_fname") & " " & mDataReader("au_lname"))

    End Sub

    Private Sub cmdStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdStop.Click
    End Sub

End Class

The form just has two buttons on it.  A Start button and a Stop button.  Clicking the Start should open the connection, read the first record and display the first and last name of the author.  It is just that simple, nothing more.  I just want to see how to read a record from a SQL Server table.

The table is in the "pubs" database in the SQL Server Group called "SV03".  The database uses Windows Authentication.

Thank you for any help.
Question by:EYoung
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

Author Comment

ID: 8019005
I solved the problem.  The following line:

Dim mSqlConnection As New SqlConnection("initial catalog=SV03.pubs;data source=authors;")

should include the "Integrated Security=SSPI" property and read as follows:

Dim mSqlConnection As SqlConnection = New SqlConnection("Data Source=SV03;Integrated Security=SSPI;Initial Catalog=pubs; ")

Thanks anyway.  I will be asking Community Services to delete this question.

Accepted Solution

modulo earned 0 total points
ID: 8019164
PAQ'd and points refunded


Community Support Moderator
Experts Exchange

Featured Post

Independent Software Vendors: 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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month11 days, 17 hours left to enroll

752 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