Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 4th, 2003, 08:55 AM
Registered User
 
Join Date: Nov 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help connecting!!!

I am trying to connect to tables I created on SQL Server 7 using VB.net, but I can't I get the error: An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll Whenever I connect to the same database but to the northwind or pubs database that is fine, it is just when I create a database then try to connect to the tables within it. Here is my code:
Imports System.Data
Imports System.Data.OleDb
Imports System.DBNull

Public Class Form1
    Inherits System.Windows.Forms.Form
    Dim objconnection As OleDbConnection = New OleDbConnection("Provider=SQLOLEDB;" & _
    "Datasource=Intranet;Initial Catalog=heads;" & _
    "integrated Security=SSPI;")
    Dim objdataadapter As OleDbDataAdapter
    Dim objdataset As DataSet
    Dim objdataview As DataView
    Dim objcurrencymanager As CurrencyManager

 objdataview = Nothing
        objdataset = New DataSet
        objconnection.Open()
        objdataadapter = New OleDbDataAdapter("SELECT quotekey FROM quotes", objconnection)
        objdataadapter.Fill(objdataset, "quotes")
        objdataview = New DataView(objdataset.Tables("quotes"))
        objcurrencymanager = CType(Me.BindingContext(objdataview), CurrencyManager)
        objconnection.Close()
        objdataset = Nothing

 txtID.DataBindings.Add("Text", objdataview, "quotekey")

Any help on this matter would be greatly appreciated.

Thanks

 
Old November 4th, 2003, 09:58 AM
Ned Ned is offline
Authorized User
 
Join Date: Jun 2003
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try this

Dim objconnection As OleDbConnection = New OleDbConnection("_
    "data source=Intranet;Initial Catalog=heads;" & _
    "integrated Security=SSPI;")

-ned
 
Old November 4th, 2003, 11:04 AM
Registered User
 
Join Date: Nov 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I tried that and it says I need a provider. I created a new table under the pubs database and still can't connect to it. If I try to connect to a default table under the pubs db it connects fine. I set my table up exactly as the default one. Any thoughts??

 
Old November 4th, 2003, 12:35 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

This might be just plain silly but you might want to check your permissions in the properties of the table you're creating. I tried creating a table in Northwind and it did not inherit the same permissions as the other tables in Northwind.

Richard

 
Old November 5th, 2003, 01:34 PM
Ned Ned is offline
Authorized User
 
Join Date: Jun 2003
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Use this at the top of the module and then give a shot again
Imports System.Data.SqlClient

Dim objconnection As OleDbConnection = New OleDbConnection("_
    "database=dbname;Server=(local);" & _
    "integrated Security=SSPI;")

If you still get any problem then try to create a DSN, that will give you a clear picture why you having trouble connecting the database.

-ned





Similar Threads
Thread Thread Starter Forum Replies Last Post
Connecting pages J_H Dreamweaver (all versions) 0 January 27th, 2007 07:09 PM
Connecting to MSAccess swatishah ADO.NET 3 January 19th, 2006 12:08 AM
Connecting to server Zodd Dreamweaver (all versions) 1 May 9th, 2005 02:51 PM
connecting to a database nehalw VB.NET 0 January 5th, 2005 05:59 AM
connecting to Autocad oni VB.NET 2002/2003 Basics 4 April 19th, 2004 10:47 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.