sql view in vb.net

Please support our VB.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Reply

Join Date: Oct 2007
Posts: 10
Reputation: Pareshja is an unknown quantity at this point 
Solved Threads: 0
Pareshja Pareshja is offline Offline
Newbie Poster

sql view in vb.net

 
0
  #1
Feb 21st, 2008
Is it possible to call a sql view in vb.net? I can call stored procs, but when I change the code to read a view it says that "request for procedure failed because it is a view object"
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 16
Reputation: ads248 is an unknown quantity at this point 
Solved Threads: 0
ads248 ads248 is offline Offline
Newbie Poster

Re: sql view in vb.net

 
0
  #2
Feb 21st, 2008
A view is like a table, so wouldn't you need to SELECT data from it ?
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 24
Reputation: suganzeni is an unknown quantity at this point 
Solved Threads: 0
suganzeni suganzeni is offline Offline
Newbie Poster

Re: sql view in vb.net

 
0
  #3
Mar 4th, 2008
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()
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,640
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: sql view in vb.net

 
0
  #4
Mar 4th, 2008
use this following code :
this code needed 1 datagrid to show data.

  1. in Module :
  2. Imports System.Data
  3. Imports System.Data.SqlClient
  4.  
  5. Module Koneksi
  6. Public conn As SqlConnection
  7. Public Function GetConnect()
  8.  
  9. conn = New SqlConnection("server = YourServerName;database = YourDatabaseName;Trusted_Connection = yes")
  10. Return conn
  11. End Function
  12. End Module

procedure to show data :
  1. Private Sub Show_Data()
  2. Dim conn As SqlConnection
  3. Dim cmdStudent As New SqlCommand
  4. Dim daStudent As New SqlDataAdapter
  5. Dim dsStudent As New DataSet
  6. Dim dtStudent As New DataTable
  7.  
  8. ' Binding Data from Table Student
  9. conn = GetConnect()
  10. Try
  11. cmdStudent = conn.CreateCommand
  12. cmdStudent.CommandText = "SELECT * FROM Student"
  13. daStudent.SelectCommand = cmdStudent
  14. daStudent.Fill(dsStudent, "Student")
  15. dgStudent.DataSource = dsStudent
  16. dgStudent.DataMember = "Student"
  17. dgStudent.ReadOnly = True
  18. Catch ex As Exception
  19. MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OKOnly, "Connection Error !!")
  20. End Try
  21. End Sub

in form, in form load event or other event :
  1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  2. Show_Data()
  3. End Sub
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 15
Reputation: gomathinayagam is an unknown quantity at this point 
Solved Threads: 1
gomathinayagam gomathinayagam is offline Offline
Newbie Poster

Re: sql view in vb.net

 
0
  #5
Nov 29th, 2008
how do select two columns from table and bind the data in data grid view control in vb.net using SQl query
Regard,
A.Gomathinayagam
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,640
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: sql view in vb.net

 
0
  #6
Nov 30th, 2008
use join on your sql query.
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC