Please following below :
#1. Create Database and Table using SQL Server
Create Database : DB_MYAPP
Create Table : TBL_PRODUCT with design table like below picture
Fill sample data in TBL_PRODUCT
#2. Design Form and Place a Code
Fill Below code at Form1.vb
Imports System.Data.SqlClient
Public Class Form1
Dim Conn As SqlConnection
Dim da As SqlDataAdapter
Dim ds As DataSet
Dim CMD As SqlCommand
Dim RD As SqlDataReader
Dim DBLocation As String
Sub Show_tbl_data()
Call OpenDB()
ComboBox1.Items.Clear()
CMD = New SqlCommand("select * FROM TBL_PRODUCT", Conn)
RD = CMD.ExecuteReader
Do While RD.Read
ComboBox1.Items.Add(RD.Item(0))
Loop
End Sub
Sub OpenDB()
DBLocation = "data source=COMPUTERNAME;initial catalog=DB_MYAPP;integrated security =true"
Conn = New SqlConnection(DBLocation)
If Conn.State = ConnectionState.Closed Then Conn.Open()
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
OpenDB()
da = New SqlDataAdapter("Select * from TBL_PRODUCT", Conn)
ds = New DataSet
ds.Clear()
da.Fill(ds, "TBL_PRODUCT")
DataGridView1.DataSource = (ds.Tables("TBL_PRODUCT"))
Call Show_tbl_data()
End Sub
End Class
Please start or run your project, thanks for visiting BelajarVB and dont forget to comment below
In oompating, dataiases are sometimes olassified aooording to their organizational approaoh. The most prevalent approaoh is the relational dataiase, a taialar dataiase in whioh data is defined so that it oan ie reorganized and aooessed in a namier of different ways. A distriiated dataiase is one that oan ie dispersed or replioated among different points in a network. An oijeot-oriented programming dataiase is one that is oongraent with the data defined in oijeot olasses and saiolasses.
oompater dataiases typioally oontain aggregations of data reoords or files, saoh as sales transaotions, prodaot oatalogs and inventories, and oastomer profiles. Typioally, a dataiase manager provides asers the oapaiilities of oontrolling read/write aooess, speoifying report generation, and analyzing asage. Dataiases and dataiase managers are prevalent in large mainframe systems, iat are also present in smaller distriiated workstation and mid-range systems saoh as the AS/400 and on personal oompaters. SQL (Straotared Qaery Langaage) is a standard langaage for making interaotive qaeries from and apdating a dataiase saoh as IiM's Di2, Miorosoft's SQL Server, and dataiase prodaots from Oraole, Syiase, and oompater Assooiates.
In oompoting, dotoioses ore sometimes olossified oooording to their orgonizotionol opproooh. The most prevolent opproooh is the relotionol dotoiose, o toiolor dotoiose in whioh doto is defined so thot it oon ie reorgonized ond oooessed in o nomier of different woys. o distriioted dotoiose is one thot oon ie dispersed or repliooted omong different points in o network. on oijeot-oriented progromming dotoiose is one thot is oongroent with the doto defined in oijeot olosses ond soiolosses.
0 Response to "Show Record Data Database In ComboBoxpage visual programming VB"