| | |
sql view in vb.net
Please support our VB.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
Join Date: Jan 2008
Posts: 24
Reputation:
Solved Threads: 0
Hi
You can view your SQl Table in vb.net with the help of DataSet and DataView.
EXAMPLE:
Dim cn3 As SqlCeConnection = Nothing
cn3 = New SqlCeConnection("Data Source=\My Documents\Databasename.sdf; " + "Password=")
Try
If cn3.State = ConnectionState.Open Then
cn3.Close()
End If
cn3.Open()
Dim da3 As New SqlCeDataAdapter("SELECT * FROM TABLENAME", cn3) '
da3.Fill(ds, "TABLENAME")
cn3.Close()
Dim dv As New DataView
dv = ds.Tables("TABLENAME").DefaultView
DataGrid1.DataSource = dv
Catch sce As SqlCeException
MessageBox.Show(sce.Message)
End Try
cn3.Close()
You can view your SQl Table in vb.net with the help of DataSet and DataView.
EXAMPLE:
Dim cn3 As SqlCeConnection = Nothing
cn3 = New SqlCeConnection("Data Source=\My Documents\Databasename.sdf; " + "Password=")
Try
If cn3.State = ConnectionState.Open Then
cn3.Close()
End If
cn3.Open()
Dim da3 As New SqlCeDataAdapter("SELECT * FROM TABLENAME", cn3) '
da3.Fill(ds, "TABLENAME")
cn3.Close()
Dim dv As New DataView
dv = ds.Tables("TABLENAME").DefaultView
DataGrid1.DataSource = dv
Catch sce As SqlCeException
MessageBox.Show(sce.Message)
End Try
cn3.Close()
use this following code :
this code needed 1 datagrid to show data.
procedure to show data :
in form, in form load event or other event :
this code needed 1 datagrid to show data.
vb.net Syntax (Toggle Plain Text)
in Module : Imports System.Data Imports System.Data.SqlClient Module Koneksi Public conn As SqlConnection Public Function GetConnect() conn = New SqlConnection("server = YourServerName;database = YourDatabaseName;Trusted_Connection = yes") Return conn End Function End Module
procedure to show data :
vb.net Syntax (Toggle Plain Text)
Private Sub Show_Data() Dim conn As SqlConnection Dim cmdStudent As New SqlCommand Dim daStudent As New SqlDataAdapter Dim dsStudent As New DataSet Dim dtStudent As New DataTable ' Binding Data from Table Student conn = GetConnect() Try cmdStudent = conn.CreateCommand cmdStudent.CommandText = "SELECT * FROM Student" daStudent.SelectCommand = cmdStudent daStudent.Fill(dsStudent, "Student") dgStudent.DataSource = dsStudent dgStudent.DataMember = "Student" dgStudent.ReadOnly = True Catch ex As Exception MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OKOnly, "Connection Error !!") End Try End Sub
in form, in form load event or other event :
vb.net Syntax (Toggle Plain Text)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Show_Data() End Sub
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
use join on your sql query.
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
![]() |
Similar Threads
- Dot Net programmer wanted. Work from home. (Web Development Job Offers)
- Converting Excel Data to MSAccess .MDB in VB.NET (VB.NET)
- Hurry! Cheap Private Label ASP.net 2/ColdFusion MX/SQL 2005 Windows Reseller Hosting! (Web Hosting Deals)
- SQL Server, Images and DataGrid in ASP.NET (ASP.NET)
- Hurry! Cheap Private Label ASP.net 2/ColdFusion MX/SQL 2005 Windows Reseller Hosting! (Web Hosting Deals)
- ASP .NET Display Random records from the database (ASP.NET)
- Simple ASP.Net Login Page (Using VB.Net) (ASP.NET)
- Invision Power Board mysql error when trying to view newly created forums (PHP)
Other Threads in the VB.NET Forum
- Previous Thread: Maze Game
- Next Thread: anyone know how to append in integer
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2005 2008 access account add arithmetic array assignment basic box button buttons center check code component connectionstring convert cpu crystalreport data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dosconsolevb.net dropdownlist editvb.net excel file-dialog firewall folder ftp generatetags hardcopy image images insert intel isnumericfuntioncall math monitor mssqlbackend mysql navigate net networking opacity output passingparameters peertopeervideostreaming picturebox1 port printpreview problem problemwithinstallation project record reports" reuse savedialog searchvb.net select serial storedprocedure string tcp temp text textbox timer toolbox trim updown user useraccounts usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web wpf






