dcsimg
Results 1 to 3 of 3

Thread: vb 2008 (9.0) and ms server

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2012
    Posts
    14

    vb 2008 (9.0) and ms server

    Hello,

    I am real new in vb. I need to connect to ms server and retrieve information for database. Just simple ''select * from ... '' ; update, delete and so on.

    If I add new data source using data source configuration wizard - everything is fine, but I want to use just simple selects.

    I use code:

    Dim connectionString As String = _
    Provider=Microsoft.Jet.OLEDB.4.0;Data Source=BBD-2;Initial Catalog=wilopumpen1;Persist Security Info=True;User ID=*****;Password=****;"
    Dim queryString As String = _
    "SELECT * from dbo.tableName "
    Using connection As New OleDbConnection(connectionString)
    Dim command As New OleDbCommand(queryString, connection)
    Try
    connection.Open()


    But it gives me error while opening connection.

    at System.Data.OleDb.OleDbServicesWrapper.GetDataSource(OleDbConnectionString constr, DataSourceWrapper& datasrcWrapper)
    at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
    at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
    at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
    at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
    at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
    at System.Data.OleDb.OleDbConnection.Open()

    What is wrong?
    Thanks.

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    103,248

    Re: vb 2008 (9.0) and ms server

    I assume that you mean MS SQL Server, in which case your connection string is wrong. The Jet 4.0 OLE DB provider is used primarily for Access MDB data files, but also for Excel XLS files and other generic formats like CSV. It is not for SQL Server. In fact, while there is an OLE DB provider for SQL Server, you should not use it if you don't have to.

    Rather than using members of the OleDb namespace, e.g. OleDbConnection, you should use the SqlClient namespace, e.g SqlConnection, which is SQL Server-specific. As such, it is more efficient and more functional. The code pattern is the same. It's just the actual types that are different.

    As for connection strings, visit www.connectionstrings.com to find the correct format for just about every common database, including SQL Server.
    Last edited by jmcilhinney; Jun 5th, 2012 at 04:08 AM. Reason: Changed SLS to XLS

  3. #3
    New Member
    Join Date
    Jun 2012
    Posts
    11

    Re: vb 2008 (9.0) and ms server

    i think this video help you this video how to display datagridview in ms access http://www.youtube.com/watch?v=x090vGtL2Qs

    in this video is for sql server 2008 http://www.youtube.com/watch?v=nZu-pLopvtw
    if you want to use sql server you must download sql server in microsoft.com/express

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width