Exforsys
+ Reply to Thread
Results 1 to 4 of 4

Problem with DataSet

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

  1. #1
    NareshShroff is offline Junior Member Array
    Join Date
    Apr 2004
    Answers
    18

    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=\")
    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\")
    myConn.Close()
    grdAuthorTitles.DataSource = myDataSet
    grdAuthorTitles.DataMember = \"test\"

    End Sub
    End Class


    ----------------------------------------
    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


  2. #2
    India Guest

    Re:Problem with DataSet

    Where is this \"grdAuthorTitles\" delared.


  3. #3
    NareshShroff is offline Junior Member Array
    Join Date
    Apr 2004
    Answers
    18

    Re:Problem with DataSet

    Im sorry gridAuthor is my gird name


  4. #4
    India Guest

    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/ShowCode.asp?ID=2226

    Last edited by admin; 02-07-2012 at 12:08 PM.

    •    Sponsored Ads



Latest Article

Network Security Risk Assessment and Measurement

Read More...