PC Review


Reply
Thread Tools Rate Thread

newby problem

 
 
campbellbrian2001@yahoo.com
Guest
Posts: n/a
 
      16th Nov 2005
Thanks all in advance. A couple of questions: I was trying to set up a
form with a datagrid to display . I have a successful attachment to an
Access Database (Northwind).
The code below failed. I had copied it as a lab exercise

(I get the following error message: "An unhandled exception of type
'System.Data.SqlClient.SqlException' occurred in system.data.dll
Additional information: System error.")

Imports System.Data
Imports System.Data.SqlClient

Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim cmd As SqlCommand = SqlConnection1.CreateCommand
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "procFranceCustomers"
Dim da As SqlDataAdapter = New SqlDataAdapter
da.SelectCommand = cmd
Dim ds As DataSet = New DataSet
da.Fill(ds, "Customers")
dgresults.DataSource = ds
dgresults.DataMember = "Customers"
End Sub
End Class

Also why does the IDE prevent me from placing Parenthecals "()" ?

Line should read Dim ds As DataSet = New DataSet()
Line should read Dim da As SqlDataAdapter = New SqlDataAdapter()

 
Reply With Quote
 
 
 
 
Earl
Guest
Posts: n/a
 
      16th Nov 2005
Use Try-Catch in your data acess code.

The reason your code fails is that you are trying to connect to Access
using SQL stored procedure, client, adapater, etc. None of that will work.

Set up with OleDB and use command text for your query (Access has no
sprocs).

You need a good book on ADO.Net.

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks all in advance. A couple of questions: I was trying to set up a
> form with a datagrid to display . I have a successful attachment to an
> Access Database (Northwind).
> The code below failed. I had copied it as a lab exercise
>
> (I get the following error message: "An unhandled exception of type
> 'System.Data.SqlClient.SqlException' occurred in system.data.dll
> Additional information: System error.")
>
> Imports System.Data
> Imports System.Data.SqlClient
>
> Public Class Form1
> Inherits System.Windows.Forms.Form
> #Region " Windows Form Designer generated code "
> #End Region
>
> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> Dim cmd As SqlCommand = SqlConnection1.CreateCommand
> cmd.CommandType = CommandType.StoredProcedure
> cmd.CommandText = "procFranceCustomers"
> Dim da As SqlDataAdapter = New SqlDataAdapter
> da.SelectCommand = cmd
> Dim ds As DataSet = New DataSet
> da.Fill(ds, "Customers")
> dgresults.DataSource = ds
> dgresults.DataMember = "Customers"
> End Sub
> End Class
>
> Also why does the IDE prevent me from placing Parenthecals "()" ?
>
> Line should read Dim ds As DataSet = New DataSet()
> Line should read Dim da As SqlDataAdapter = New SqlDataAdapter()
>



 
Reply With Quote
 
 
 
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      16th Nov 2005
Earl,

Great catch however Access has stored procedures

Cor


 
Reply With Quote
 
Earl
Guest
Posts: n/a
 
      16th Nov 2005
I've heard that rumored, but not dug into it. What version and is this a
supported feature?

"Cor Ligthert [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Earl,
>
> Great catch however Access has stored procedures
>
> Cor
>



 
Reply With Quote
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      16th Nov 2005
Earl,

Three great links once copied from a message from Paul Clement

http://msdn.microsoft.com/library/de.../acfundsql.asp

http://msdn.microsoft.com/library/de...l/acintsql.asp

http://msdn.microsoft.com/library/de...l/acadvsql.asp

I hope this helps?

Cor


 
Reply With Quote
 
Earl
Guest
Posts: n/a
 
      17th Nov 2005
Well, the 3rd link would've been enough and kept me from wading through all
the basic trivia of the first 2, but I do see that Access 2000 has
"procedures" used similar to an SQL stored procedure. Not that I use Access
much anymore, but good info to know.

But before we lose the OP entirely, the gist of the answer is still correct
in that he was trying to connect to Access
using SQL stored procedure, client, adapater, etc. -- which will not work
(and while it's possible, I further doubt he had a "procedure" built in
Access that he was calling).

"Cor Ligthert [MVP]" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Earl,
>
> Three great links once copied from a message from Paul Clement
>
> http://msdn.microsoft.com/library/de.../acfundsql.asp
>
> http://msdn.microsoft.com/library/de...l/acintsql.asp
>
> http://msdn.microsoft.com/library/de...l/acadvsql.asp
>
> I hope this helps?
>
> Cor
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
another front page newby with a mac problem =?Utf-8?B?c2lhbWV6ZXI=?= Microsoft Frontpage 5 3rd Sep 2007 02:41 AM
Newby delegate problem - syntax problems I guess Cosmin Prund Microsoft C# .NET 5 16th Nov 2005 08:23 AM
Win XP problem; and a question - newby John Windows XP New Users 6 10th Apr 2005 01:33 PM
I'm a Newby Dekkerfish Introductions 5 12th Nov 2004 06:23 PM
Newby Connection Problem Mary Robbins Microsoft Frontpage 1 3rd Sep 2003 12:59 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:22 AM.