6 Replies - 12135 Views - Last Post: 01 April 2012 - 09:41 AM Rate Topic: -----

#1 shehzi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 21-March 11

how to use datagrid view in vb.net

Posted 01 April 2012 - 05:19 AM

i want to access the data stored in ma sql server using datagrid using vb.net. :helpsmilie:
i loaded it but i when i change the contents in the datagrid once when i run, these changes doesnt get updated in my sql server. how can i solve this?

This post has been edited by shehzi: 01 April 2012 - 05:21 AM

Is This A Good Question/Topic? 0
  • +

Replies To: how to use datagrid view in vb.net

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6052
  • View blog
  • Posts: 23,487
  • Joined: 23-August 08

Re: how to use datagrid view in vb.net

Posted 01 April 2012 - 05:39 AM

SHOW. YOUR. CODE.
Was This Post Helpful? 0
  • +
  • -

#3 shehzi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 21-March 11

Re: how to use datagrid view in vb.net

Posted 01 April 2012 - 06:49 AM

View PostJackOfAllTrades, on 01 April 2012 - 06:09 PM, said:

SHOW. YOUR. CODE.
please do help me out :helpsmilie:
    Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'BillingDataSet.stock' table. You can move, or remove it, as needed.
        Me.StockTableAdapter.Fill(Me.BillingDataSet.stock)

        Dim connectionstring As String = "server=LAP\SQLEXPRESS;uid=;pwd=;database=billing;Integrated security=true"


        Dim sql As String = "SELECT * FROM stock"
        Dim connection As New SqlConnection(connectionstring)
        Dim dataadapter As New SqlDataAdapter(sql, connection)
        Dim ds As New DataSet()
        connection.Open()
        dataadapter.Fill(ds, "stock_table")
        connection.Close()
        DataGridView1.DataSource = ds
        DataGridView1.DataMember = "stock_table"

    End Sub

Was This Post Helpful? 0
  • +
  • -

#4 shehzi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 21-March 11

Re: how to use datagrid view in vb.net

Posted 01 April 2012 - 09:27 AM

i want to access the data stored in ma sql server using datagrid using vb.net.
i loaded it but i when i change the contents in the datagrid once when i run, these changes doesnt get updated in my sql server. how can i solve this?
[/quote] please do help me out :helpsmilie:
Public Class Form5
    Dim mycommand As SqlCommand
    Dim ra As Integer
    Dim ra1 As Integer
    Dim dr As SqlDataReader
    Dim myconnection As SqlConnection
    Dim sql As String
    Dim item As String
    Dim adapter As New SqlDataAdapter
    Dim dict As New Dictionary(Of String, Integer)
    Dim c As Integer

    Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'BillingDataSet.stock' table. You can move, or remove it, as needed.
        Me.StockTableAdapter.Fill(Me.BillingDataSet.stock)

        Dim connectionstring As String = "server=LAP\SQLEXPRESS;uid=;pwd=;database=billing;Integrated security=true"


        Dim sql As String = "SELECT * FROM stock"
        Dim connection As New SqlConnection(connectionstring)
        Dim dataadapter As New SqlDataAdapter(sql, connection)
        Dim ds As New DataSet()
        connection.Open()
        dataadapter.Fill(ds, "stock_table")
        connection.Close()
        DataGridView1.DataSource = ds
        DataGridView1.DataMember = "stock_table"

    End Sub

[/quote]

This post has been edited by shehzi: 01 April 2012 - 09:31 AM

Was This Post Helpful? 0
  • +
  • -

#5 shehzi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 21-March 11

Re: how to use datagrid view in vb.net

Posted 01 April 2012 - 09:31 AM

i want to access the data stored in ma sql server using datagrid using vb.net.
i loaded it but i when i change the contents in the datagrid once when i run, these changes doesnt get updated in my sql server. how can i solve this?
[/quote] please do help me out :helpsmilie:
Public Class Form5
    Dim mycommand As SqlCommand
    Dim ra As Integer
    Dim ra1 As Integer
    Dim dr As SqlDataReader
    Dim myconnection As SqlConnection
    Dim sql As String
    Dim item As String
    Dim adapter As New SqlDataAdapter
    Dim dict As New Dictionary(Of String, Integer)
    Dim c As Integer

    Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'BillingDataSet.stock' table. You can move, or remove it, as needed.
        Me.StockTableAdapter.Fill(Me.BillingDataSet.stock)

        Dim connectionstring As String = "server=LAP\SQLEXPRESS;uid=;pwd=;database=billing;Integrated security=true"


        Dim sql As String = "SELECT * FROM stock"
        Dim connection As New SqlConnection(connectionstring)
        Dim dataadapter As New SqlDataAdapter(sql, connection)
        Dim ds As New DataSet()
        connection.Open()
        dataadapter.Fill(ds, "stock_table")
        connection.Close()
        DataGridView1.DataSource = ds
        DataGridView1.DataMember = "stock_table"

    End Sub

[/quote]
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9057
  • View blog
  • Posts: 34,001
  • Joined: 12-June 08

Re: how to use datagrid view in vb.net

Posted 01 April 2012 - 09:39 AM

Where's your update query? Where's the event that is supposed to trigger this update?

What you have there is a request, to the database, for a chunk of information.. that information is stored in your dataset and that's set to your grid. There's no open line of communication setup. You copied a parcel of data and are using that copy. The computer doesn't implicitly know you want to update anything or even where the updates to that copied data goes. *YOU* have to do that part!
Was This Post Helpful? 0
  • +
  • -

#7 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9057
  • View blog
  • Posts: 34,001
  • Joined: 12-June 08

Re: how to use datagrid view in vb.net

Posted 01 April 2012 - 09:41 AM

Do not create duplicate topics.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1