Results 1 to 10 of 10

Thread: basic help!!!

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2007
    Posts
    10

    basic help!!!

    I am fresh on vb.net 2005 - i tried to develop a simple windows .net framework application and want to use sqlserver db into it. when i tried to use this code:
    dim myConn as new SqlConnection
    it doesn't recognizes and raise an exception to change it to:
    dim myConn as new sqlClient.SqlConnection

    when i use the sqlclient.sqlconnection and runs the application, it raise an error that its not working to call a client remote connection???

    can anyone help me to write codes to:
    - connect sqlserver db
    - dataadapter, datareader etc?

    cheers

  2. #2
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: basic help!!!

    Ok - where is the SQL server? Is it on your machine or on your network - or remote to your machine?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2007
    Posts
    10

    Re: basic help!!!

    sql server express 2005 is installed on my pc along with vs2005. my computer name is pc1 and database name is TEST under d:\testApp

    hope its ok and thx in advance for next reply!

    cheers

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: basic help!!!

    This is what I use to connection to an SQL Server database that is on our local network.
    Code:
    Imports System.Data.SqlClient
    
        Public myConnection As SqlConnection
    
        Public Sub OpenDB()        
            myConnection = New SqlConnection("Integrated Security=SSPI;" _
         & "Persist Security Info=False;Initial Catalog=XXXXXXX; " _
         & "Data Source=XXXXXXXXXX")
            myConnection.Open()
        End Sub

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2007
    Posts
    10

    Re: basic help!!!

    well thx but this doesn't work either. i m using the following codes:

    Dim Database As String = "[test]"
    Dim ServerName As String = "[local]"
    Dim ConString As String = "Server=" & ServerName & ";Initial Catalog=" & Database & ";User ID=;Password="
    Dim connection As New SqlConnection(ConString) ' connect to the db
    Dim success As String
    Try
    connection.Open()
    success = "sql connection successful..."
    Catch 'errormessage
    success = Err.Description
    End Try
    Dim form1 As New Form1
    MsgBox(success)

    end sub

    it raise an exception error message saying:
    an error has occured while establishing a connection to the server. when connection to sql server 2005, this failure may be caused by the fact that uneder the default settings SQL server does not allow remote connections. (provider: names pipes provider, error: 40 - could not open a connection to sql server)

    any idea?

    cheers

  6. #6
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: basic help!!!

    Seems odd that it's a local instance of sql giving you that error...

    At any rate - do this.

    Start>All Programs>Microsoft SQL 2005>Configuration Tools>SQL Server Surface Area Configuration

    Select Surface Area Config Services and Connections

    Expand the server node - database engine - Remote Connections

    What is checked off?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  7. #7

    Thread Starter
    New Member
    Join Date
    Jul 2007
    Posts
    10

    Re: basic help!!!

    its set on Local connections only while the other option Local and Remote connections is off

    what to do?

    cheers

  8. #8
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: basic help!!!

    Try setting it to Local and Remote connections.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  9. #9

    Thread Starter
    New Member
    Join Date
    Jul 2007
    Posts
    10

    Re: basic help!!!

    no m8 - it doesn't work either!

    Can u pls send me tips to use MS Access db instead of Sql Server? atleast i can get on to some stuff and try to resolve the sql server issue some other time?

    cheers

  10. #10
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: basic help!!!

    well - the server name is not [LOCAL]

    on my laptop - with a name of FPS-LAP-SZ - the SQL EXPRESS instance is called:

    FPS-LAP-SZ\SQLEXPRESS

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width