Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics 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 September 29th, 2004, 10:39 AM
Registered User
 
Join Date: Sep 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Code Problem trying to learn about datagrids

Dim objDataSet As [u]DataSet</u> = New DataSet (Keeps saying that type is expeected for DataSet, but I copied the code directly from the book).

Maybe Next Time...
 
Old October 1st, 2004, 08:05 AM
Friend of Wrox
 
Join Date: Sep 2004
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Anantsharma Send a message via Yahoo to Anantsharma
Default

Hey,

Seems u r working on VB.NET. Its not like VB Code. If u r on VB.NET. make sure to import System.Data.SQLClient namespace. In Books, every block doesn't shows these things. They use to warn this at starting of book. Further u have to take care to include such things.

Hope u got the idea. Bette if u can Provide some more code segment whatever u have written.

B. Anant
 
Old October 1st, 2004, 09:03 PM
Registered User
 
Join Date: Sep 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

yeah i imported that namespace i simplly called wrox and emailed them, but here is my code.

Imports System.Data
Imports System.Data.SqlClient

Public Class Form1
    Inherits System.Windows.Forms.Form

    Dim objconnection As SqlConnection = New _
        SqlConnection("server=(local);database=Company;use r id=sa;password=")

    Dim objDataAdapter As New SqlDataAdapter
    Dim objDataSet As DataSet = New DataSet

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        objDataAdapter.SelectCommand = New SqlCommand
        objDataAdapter.SelectCommand.Connection = objconnection
        objDataAdapter.SelectCommand.CommandText = _
            "SELECT CompanyName, Address, Phone" & _
            "FROM Companies"
        objDataAdapter.SelectCommand.CommandType = CommandType.Text

        objconnection.Open()

        objDataAdapter.Fill(objDataSet, "companies")

        objconnection.Close()

        grdCompany.DataSource = objDataSet
        grdCompany.DataMember = "companies"

        objDataAdapter = Nothing
        objconnection = Nothing


Maybe Next Time...





Similar Threads
Thread Thread Starter Forum Replies Last Post
datagrids dhoward VB.NET 2002/2003 Basics 8 May 24th, 2007 09:07 AM
Datagrids dhoward VB.NET 2002/2003 Basics 1 January 2nd, 2007 01:06 AM
Nested DataGrids Manu General .NET 2 May 4th, 2006 12:56 AM
Datagrids Louisa VB.NET 2002/2003 Basics 2 September 25th, 2004 09:55 AM
Refreshing Datagrids Louisa VB.NET 2002/2003 Basics 13 May 11th, 2004 09:17 AM





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