Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Visual Basic 2010 General Discussion For any discussions about Visual Basic 2010 topics which aren't related to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2010 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 3rd, 2012, 05:19 PM
Registered User
Points: 34, Level: 1
Points: 34, Level: 1 Points: 34, Level: 1 Points: 34, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2011
Posts: 9
Thanks: 2
Thanked 0 Times in 0 Posts
Default OdbcConnection

In this block of code I am simply trying to open an access 2010 database (accdb) and fill a data table. However when code is run I get
error [IM002][Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified.

On a different form I use a DataGridView, DataSet, BindingSource and a
TableAdapter for the toolbox to open and view the same table, which functions fine.
The web is pointing me to the connection str, however I cannot find what is wrong. Any help is of course appreciated
Code:
Imports System.Data.Odbc

Public Class Form1

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        Dim conn As OdbcConnection
        Dim cmd As OdbcCommand
        Dim da As OdbcDataAdapter
        Dim query As String
        Dim connString As String = ""
        connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Rick\Desktop\Aeroparts.accdb;Persist Security Info=False;"

        query = "SELECT[*] FROM [Statuscodes]"
        'Create the connection object
        conn = New OdbcConnection(connString)
        'Open connection
        cmd = New OdbcCommand(query, conn)
        da = New OdbcDataAdapter(cmd)
        Dim AeroPartsDataSet = New DataSet()
        Dim StationTimeTable As DataTable = AeroPartsDataSet.Tables.Add("StationTimeTable")

        Try
            conn.Open()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical)
        End Try
        Try
            'da.Fill(StationTimeTable)
            da.Dispose() 'close data adapter
            conn.Close() 'close connect to Spreadsheet
            conn.Dispose() 'do cleanup of connection enviroment
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical)
        End Try

    End Sub


End Class
Reply With Quote
  #2 (permalink)  
Old April 4th, 2012, 07:43 AM
Registered User
Points: 16, Level: 1
Points: 16, Level: 1 Points: 16, Level: 1 Points: 16, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for replying.

I have one more problem if u can help me..

Wants to add new row and delete row to data bounded grid.
data is bounded through tools from tool box, binding source ,data set.
Whatever changes made is upto data set only, not able to save it to database.

I searched and found that new row can be added to data source directly. but How?...
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
have a query in gridview using odbcconnection .. catchkishan Visual Web Developer 2005 0 February 7th, 2006 04:54 AM



All times are GMT -4. The time now is 06:11 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.