如何从Vb.Net中的Datagridview中的单元格条目中获取数据库中的数据 [英] How Do I Get Data From Database On Cell Entry In The Datagridview In Vb.Net
本文介绍了如何从Vb.Net中的Datagridview中的单元格条目中获取数据库中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从vb.net中的datagridview本身的单元格条目中获取ms-access到datagridview的数据。
how do i get the data from the ms-access into the datagridview on cell entry in the datagridview itself in the vb.net.
推荐答案
Imports System.Data
Imports System.Data.SqlClient
Public Class frmattendence
Dim con As New SqlConnection("Data Source=Tarun-PC;Initial Catalog=couriermanagementsystem;Integrated Security=True")
Private da As SqlDataAdapter
Private dt As DataTable
Private ds As DataSet
Private cmdselect, cmddelete As String
Private Sub frmattendence_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'Calling this method for execution whrn form loads
LoadRecord()
End Sub
'This method calls values from database put in datagridview
' Actually you have to Focus on this part only
Private Sub LoadRecord()
cmdselect = "select ID,Name,Gender,Position from tblcouriercompany"
da = New SqlDataAdapter(cmdselect, con)
dt = New DataTable()
da.Fill(dt)
DataGridView1.DataSource = dt
End Sub
这篇关于如何从Vb.Net中的Datagridview中的单元格条目中获取数据库中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文