Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 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 February 7th, 2005, 07:19 PM
Registered User
 
Join Date: Feb 2005
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL Server with ADO.NET

Hi everyone,

This error what i get when i run the code below
 "An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll"

after this error message i chose "breake" then the cursor indicates to this line with green line

 objConnection.open()

is this error from dll files or sql setting or ...
with using vb.net & sql server 2000
-----------------------------
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
    Inherits System.Windows.Forms.Form
    Dim objConnection As OleDbConnection = New _
    OleDbConnection("Provider=SQLOLEDB.1" & _
    "Data Source =HOMEPC;Initial Catalog=pubs;" & _
"Integradted Security=SSPI;")
    Dim objDataAdapter As New OleDbDataAdapter
    Dim objDataSet As DataSet = New DataSet


 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ' Set the SelectCommand properties...
        objDataAdapter.SelectCommand = New OleDbCommand
        objDataAdapter.SelectCommand.Connection = objConnection
        objDataAdapter.SelectCommand.CommandText = _
            "SELECT au_lname, au_fname, title, price " & _
            "FROM authors " & _
            "JOIN titleauthor ON authors.au_id = titleauthor.au_id " & _
            "JOIN titles ON titleauthor.title_id = titles.title_id " & _
            "ORDER BY au_lname, au_fname"
        objDataAdapter.SelectCommand.CommandType = CommandType.Text
        objConnection.Open()
        objDataAdapter.SelectCommand = New OleDbCommand
        objDataAdapter.SelectCommand.Connection = objConnection
        objDataAdapter.SelectCommand.CommandText = _
        "SELECT au_lname, au_fname; title, price " & _
        "JOIN titleauthor ON authors.au_id = titlauthor.au_id " & _
        "JOIN titles ON titleauthor.title_id = titles.title_id " & _
        "ORDER BY au_lname,au_fname"
        objDataAdapter.SelectCommand.CommandType = CommandType.Text
        objDataAdapter.SelectCommand.ExecuteNonQuery()
        objDataAdapter.Fill(objDataSet, "authors")
        objConnection.Close()
        objDataAdapter = Nothing
        objConnection = Nothing
        grdAuthorTitles.DataSource = objDataSet
        grdAuthorTitles.DataMember = "authors"
-------------------------------------------------------




Reply With Quote
  #2 (permalink)  
Old February 8th, 2005, 08:20 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,111
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Why are you using OleDB with SQL Server?


Reply With Quote
  #3 (permalink)  
Old February 8th, 2005, 08:29 AM
Registered User
 
Join Date: Feb 2005
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for reply
Why i use OleDb with SQl really i dont know
but this code is in the beginning vb.net book


Reply With Quote
  #4 (permalink)  
Old February 8th, 2005, 08:40 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,111
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Try using Imports System.Data.SqlClient and changing all OleDB to SQL in your code.

Proper connection string.
http://www.connectionstrings.com/

Reply With Quote
  #5 (permalink)  
Old February 8th, 2005, 08:19 PM
Registered User
 
Join Date: Feb 2005
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi again,

With this declaration

Dim myConnection As SqlConnection = New _
        SqlConnection("server=HOMEPC;database=pubs;Integra ted Security=SSPI;")
    Dim myDataAdapter As New SqlDataAdapter
    Dim myDataSet As DataSet = New DataSet


 AND THIS IS THE ERROR MSG



An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll

Additional information: System error.



When i using sql rather than OleDb,in the OleDb the cursor indicate o
objConnnection.open ()

but with sql the cursor indicate to

myDataAdapter.SelectCommand.ExecuteNonQuery()




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
ADO.NET connectivity problem with SQL Server !!! virajp ADO.NET 2 December 5th, 2005 10:51 PM
ADO.Net slower than SQL Server Query Analyzer s5g5r ADO.NET 1 January 26th, 2005 08:49 PM
how can i link to sql-server with ado.net[B)] zjxgjp ADO.NET 1 December 25th, 2004 08:50 AM
Ado.net performance question (SQL server vs OleDB spamp ADO.NET 1 August 2nd, 2004 10:37 AM
MSDE and SQL CE (using VB.NET and ADO.NET) LEGS ADO.NET 0 July 12th, 2003 11:27 AM



All times are GMT -4. The time now is 05:01 AM.


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