What is wrong with this vb.net code?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • navanova
    New Member
    • Feb 2007
    • 30

    What is wrong with this vb.net code?

    Hi there, I've used the following function as part of a code to connect my vb.net application to sql server 2000. However, the underlined code below (at the while statement) says: "Operator '=' is not defined for types 'System.Data.Sq lClient.SqlConn ection' and 'System.Data.Sq lClient "

    What is wrong with it?

    Thank you,

    Public Shared Function ManiCon() As SqlConnection
    servername = CType(GetSystem Setting("Server ", ""), String)
    database = CType(GetSystem Setting("Databa se", ""), String)
    username = CType(GetSystem Setting("Userna me", ""), String)
    password = CType(GetSystem Setting("Passwo rd", ""), String)

    Dim con As SqlConnection

    Dim cs As OAMS.Common.Con nctionSetting = New OAMS.Common.Con nctionSetting()

    While (con = connect(servern ame, database, username, password)) Is Nothing
    If (connect(server name, database, username, password)) Is Nothing Then

    If cs.ShowDialog() = System.Windows. Forms.DialogRes ult.OK Then
    Return Nothing
    End If

    servername = cs.Server
    database = cs.Database
    username = cs.Username
    password = cs.Password


    End If
    SetSystemSettin g("Server", servername)
    SetSystemSettin g("Database", database)
    SetSystemSettin g("Username", username)
    SetSystemSettin g("Password", password)
    End While
    Return con



    End Function
  • shweta123
    Recognized Expert Contributor
    • Nov 2006
    • 692

    #2
    Hi,

    What are you trying to do by
    While (con = connect(servern ame, database, username, password))?
    Are you checking wheather connection is done or not?
    Instead of that you can check for Connect Timeout in the ConnectionStrin g and
    simply say connect(servern ame, database, username, password))

    Comment

    • avkdsiva
      New Member
      • Mar 2007
      • 23

      #3
      You did not write the definition of connect function that you are using.
      Probably the return type of it may not be same as that of the con (SqlConnection)

      Comment

      • navanova
        New Member
        • Feb 2007
        • 30

        #4
        Dear shweta123 & avkdsiva,

        Thank you for your prompt and helpful responce.

        Thanks again,

        Comment

        Working...