Exforsys

Online Training

Problem with DataSet

This is a discussion on Problem with DataSet within the Microsoft .NET Tutorials and Articles forums, part of the Articles and Tutorials category; Hi, im a newbie in .net. im trying to display the data in a datagrid using DataSet. but im getting ...


Go Back   Exforsys > Articles and Tutorials > Microsoft .NET Tutorials and Articles

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-25-2004, 07:17 PM
Member
 
Join Date: Apr 2004
Posts: 37
NareshShroff
Problem with DataSet

Hi,
im a newbie in .net.
im trying to display the data in a datagrid using DataSet. but im getting an error saying \"type expected\" this error is for dataset declaration. i dont know whats wrong with the declaration.
Can anyone help me please.
thanks in advance.

here is the code


Imports System.Data
Imports System.Data.SqlClient

Public Class Form1
Inherits System.Windows.Forms.Form

Dim myConn As SqlConnection = New SqlConnection(\"server=(local);database=tempdb;uid=;pwd=\&quot
Dim myDAdapter As New SqlDataAdapter
Dim myDataSet As Dataset = New Dataset \'Error is with DataSet

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

myDAdapter.SelectCommand = New SqlCommand
myDAdapter.SelectCommand.Connection = myConn
myDAdapter.SelectCommand.CommandText = _
\"SELECT * from test\"
myDAdapter.SelectCommand.CommandType = CommandType.Text

myConn.Open()
myDAdapter.SelectCommand.ExecuteNonQuery()

myDAdapter.Fill(myDataSet, \"test\&quot
myConn.Close()
grdAuthorTitles.DataSource = myDataSet
grdAuthorTitles.DataMember = \"test\"

End Sub
End Class


----------------------------------------
Quote:
Dim myDataSet As Dataset = New Dataset
actually i tried to type DataSet() but it only takes Dataset. i dont know whether that might be the problem.
and i even tried
Dim myDataSet As New Dataset
still im getting the same error
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-26-2004, 04:22 AM
India
Guest
 
Posts: n/a
Re:Problem with DataSet

Where is this \"grdAuthorTitles\" delared.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-26-2004, 05:14 AM
Member
 
Join Date: Apr 2004
Posts: 37
NareshShroff
Re:Problem with DataSet

Im sorry gridAuthor is my gird name
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-26-2004, 05:35 AM
India
Guest
 
Posts: n/a
Re:Problem with DataSet

try this to get started and getting familier with the database and vbcontrols.

this is full working source code.

Version Compatibility: Visual Basic.NET


More information: Updated for VB.NET Version 1.0, 03/07/02. If you have trouble running in in IDE, try running the .exe

This application provides a detailed and excellent introduction to the new ADO.NET object model. It allows you to connect to an Access or SQL Server database, explore its structure, and run querires against it using its own Query Analyzer.

To run the application, download and extract the .zip file and Open the solution file named as DatabaseExplorer.sln.

In the case of Access, it is designed to be used for password-protected databases and requires you to identify the System Database for Access (generally in C:\\Program files\\Microsoft office\\Office\\System.mdw). When you connect to the Access database, the application reads the MSysObjects table (see the Query in Connect Method of the CAccessDatabase class), so permission to read this table must be granted to the user. In the case of SQL, login works as it does in the SQL query analyzer, except you have to identify the database you want to view in the login screen.

This code has been viewed 62687 times.

Instructions: Click the link below to download the code. Select \'Save\' from the IE popup dialog. Once downloaded, open the .zip file from your local drive using WinZip or a comparable program to view the contents.

http://www.freevbcode.com/code/VBNET...seExplorer.zip

http://www.freevbcode.com/ShowCode.asp?ID=2226
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 05-26-2004, 06:18 AM
Member
 
Join Date: Apr 2004
Posts: 37
NareshShroff
Re:Problem with DataSet

Thanks India
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools

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 On



All times are GMT -4. The time now is 01:23 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2004 - 2007 Exforsys Inc. All rights reserved.