Connection string working with 2005 but failing with 2003.

I hv a glaring issue and no solution—

This code works fine in VS 2005 but fails in Vs.NET 2003.

Using OLEDB, it works in VS.NET 2003, but the code used below fails. I cannot change the lines below and cannot upgrade the solution to VS 2005.

Now pl tell me what s going wrong!! I seriously lack experts here to bail me out J

Imports System.Data.SqlClient

Imports System.Exception

Public Class Form1

Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()

MyBase.New()

'This call is required by the Windows Form Designer.

InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

'Required by the Windows Form Designer

Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer.

'Do not modify it using the code editor.

Friend WithEvents Button1 As System.Windows.Forms.Button

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

Me.Button1 = New System.Windows.Forms.Button

Me.SuspendLayout()

'

'Button1

'

Me.Button1.Location = New System.Drawing.Point(88, 194)

Me.Button1.Name = "Button1"

Me.Button1.Size = New System.Drawing.Size(96, 48)

Me.Button1.TabIndex = 0

Me.Button1.Text = "Connect to DB"

'

'Form1

'

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

Me.ClientSize = New System.Drawing.Size(292, 273)

Me.Controls.Add(Me.Button1)

Me.Name = "Form1"

Me.Text = "Form1"

Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim sConnect As String

Dim adoConn As SqlConnection

Try

' sConnect = "SERVER=10.48.136.157;UID=Maxmillion;PWD=peabody;DATABASE=Insurance_383;" _

'& "connect timeout=0;"

sConnect = "data source=tcp:10.48.136.157;Initial Catalog=Insurance_383;User ID=Maxmillion;Password=peabody;"

adoConn = New SqlConnection

adoConn.ConnectionString = sConnect

'adoConn.Open(sConnect)

adoConn.Open()

MsgBox("Yeh!! we got connected", MsgBoxStyle.Information)

adoConn.Close()

adoConn.Dispose()

Catch exSQL As SqlException

MsgBox(exSQL.Message, MsgBoxStyle.Information, "Connection Error")

Catch ex As Exception

ex.Source = ex.Source & vbCr & "form1->button1_Click"

MessageBox.Show(ex.ToString)

Finally

adoConn.Dispose()

End Try




Answer this question

Connection string working with 2005 but failing with 2003.

  • Visio User

    SQL Server doesn't exist or Access denied at adoConn.Open()

    Thanks,

    Hitesh



  • Ensynch

    Hello!

    Did you ever find a solution for this issue I'm having the exact same symptoms. I upgraded from MSDE 2000 to Sql Server 2005 (Standard), and now I cannot connect from VS2003 via the SqlClient objects. OleDB works great, and I have no problems in VS 2005's SqlClient objects. All three products are on the same machine, so it's not a network issue.

    Thanks in advance!

    Terry



  • uconnbizniss

    What is the error message
  • Kandikan

    Why do you put 'tcp' before your IP adress
    Is your sql server listening at the default port

    Change the connectionstring to this:
    "Data Source=10.48.136.157,1433;Initial Catalog=Insurance_383;User ID=Maxmillion;Password=peabody;

  • kowalsky

    It's neither working for the specified connectionstring nor for the localhost.

  • Phil Seastrand

    Please check,if the client protocols are enabled under configuration manager of SQLServer 2005


  • Connection string working with 2005 but failing with 2003.