PC Review


Reply
Thread Tools Rate Thread

can't display data from an SQL server viewtable

 
 
Patrick Sullivan
Guest
Posts: n/a
 
      16th Aug 2005

I have a view of 3 tables joined with IDs named "appsvw" I can't get it to
display in my datagrid1. code is below. TIA.

Protected Const CONNECTION_STRING As String = _
"Server=localhost;" & _
"DataBase=Jsearch;" & _
"Integrated Security=SSPI;Connect Timeout=5"

Private ConnectionString As String = CONNECTION_STRING
Private tdsdata As DataSet1

Private Sub AppsForm_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim con As New SqlConnection(ConnectionString)
tdsdata = New DataSet1
Dim adapter As SqlDataAdapter = New SqlDataAdapter("SELECT * FROM
appsvw", con)
con.Open()
adapter.Fill(tdsdata)
con.Close()
DataGrid1.DataSource = tdsdata
DataGrid1.DataMember = "appsvw"
End Sub


viewtable creation
CREATE VIEW dbo.appsvw AS
SELECT TOP 1000 dbo.Positions.posName AS [Position], dbo.Companies.compName
AS Company, dbo.Applications.appDate AS [Date],
dbo.Applications.appNotes AS Notes,
dbo.Applications.appID AS ID
FROM
dbo.Companies INNER JOIN
dbo.Applications ON
dbo.Companies.compID = dbo.Applications.appCompany INNER JOIN
dbo.Positions ON
dbo.Applications.appPosition = dbo.Positions.posID
ORDER BY dbo.Applications.appID

TIA
--

Patrick Sullivan, AA-BA, BA-IT


 
Reply With Quote
 
 
 
 
Mark Ashton
Guest
Posts: n/a
 
      16th Aug 2005
try this
adapter.Fill(tdsdata, "appsvw")
or
DataGrid1.DataMember = "Table"

When an adapter.Fill(dataset) is called, which table should it map to or
create. Against sql server, by default the client doesn't have any metadata
information other than column name and type. If we did have metadata
information it would have the basetable information for where the column
originated - not the views. With your three tables in the view, which
table would should be picked. By default adapter.Fill(DataSet) will fill
DbDataAdapter.DefaultSourceTableName which is "Table".

--
This posting is provided "AS IS", with no warranties, and confers no rights.
Please do not send email directly to this alias. This alias is for newsgroup
purposes only.

"Patrick Sullivan" <(E-Mail Removed)> wrote in message
news:4OSdnQFpuIR_sJzeRVn-(E-Mail Removed)...
>
> I have a view of 3 tables joined with IDs named "appsvw" I can't get it
> to
> display in my datagrid1. code is below. TIA.
>
> Protected Const CONNECTION_STRING As String = _
> "Server=localhost;" & _
> "DataBase=Jsearch;" & _
> "Integrated Security=SSPI;Connect Timeout=5"
>
> Private ConnectionString As String = CONNECTION_STRING
> Private tdsdata As DataSet1
>
> Private Sub AppsForm_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
>
> Dim con As New SqlConnection(ConnectionString)
> tdsdata = New DataSet1
> Dim adapter As SqlDataAdapter = New SqlDataAdapter("SELECT * FROM
> appsvw", con)
> con.Open()
> adapter.Fill(tdsdata)
> con.Close()
> DataGrid1.DataSource = tdsdata
> DataGrid1.DataMember = "appsvw"
> End Sub
>
>
> viewtable creation
> CREATE VIEW dbo.appsvw AS
> SELECT TOP 1000 dbo.Positions.posName AS [Position],
> dbo.Companies.compName
> AS Company, dbo.Applications.appDate AS [Date],
> dbo.Applications.appNotes AS Notes,
> dbo.Applications.appID AS ID
> FROM
> dbo.Companies INNER JOIN
> dbo.Applications ON
> dbo.Companies.compID = dbo.Applications.appCompany INNER JOIN
> dbo.Positions ON
> dbo.Applications.appPosition = dbo.Positions.posID
> ORDER BY dbo.Applications.appID
>
> TIA
> --
>
> Patrick Sullivan, AA-BA, BA-IT
>
>



 
Reply With Quote
 
Patrick Sullivan
Guest
Posts: n/a
 
      16th Aug 2005
Hey Mark, thanks a lot! This is what finally worked! BTW, There is no table
in the query, it's just three tables joined in an SQL server 2000 view, so
the view IS the table, from what I understand. It's the only way I can see
to display data from 3 tables in a single datagrid row with no child table
controls.

adapter.Fill(tdsdata, "appsvw")

con.Close()

DataGrid1.DataSource = tdsdata

DataGrid1.DataMember = "appsvw"


--

Patrick Sullivan, AA-BA, BA-IT

"Mark Ashton" <(E-Mail Removed)> wrote in message
news:u%(E-Mail Removed)...
> try this
> adapter.Fill(tdsdata, "appsvw")
> or
> DataGrid1.DataMember = "Table"
>
> When an adapter.Fill(dataset) is called, which table should it map to or
> create. Against sql server, by default the client doesn't have any

metadata
> information other than column name and type. If we did have metadata
> information it would have the basetable information for where the column
> originated - not the views. With your three tables in the view, which
> table would should be picked. By default adapter.Fill(DataSet) will fill
> DbDataAdapter.DefaultSourceTableName which is "Table".
>
> --
> This posting is provided "AS IS", with no warranties, and confers no

rights.
> Please do not send email directly to this alias. This alias is for

newsgroup
> purposes only.
>
> "Patrick Sullivan" <(E-Mail Removed)> wrote in message
> news:4OSdnQFpuIR_sJzeRVn-(E-Mail Removed)...
> >
> > I have a view of 3 tables joined with IDs named "appsvw" I can't get it
> > to
> > display in my datagrid1. code is below. TIA.
> >
> > Protected Const CONNECTION_STRING As String = _
> > "Server=localhost;" & _
> > "DataBase=Jsearch;" & _
> > "Integrated Security=SSPI;Connect Timeout=5"
> >
> > Private ConnectionString As String = CONNECTION_STRING
> > Private tdsdata As DataSet1
> >
> > Private Sub AppsForm_Load(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles MyBase.Load
> >
> > Dim con As New SqlConnection(ConnectionString)
> > tdsdata = New DataSet1
> > Dim adapter As SqlDataAdapter = New SqlDataAdapter("SELECT * FROM
> > appsvw", con)
> > con.Open()
> > adapter.Fill(tdsdata)
> > con.Close()
> > DataGrid1.DataSource = tdsdata
> > DataGrid1.DataMember = "appsvw"
> > End Sub
> >
> >
> > viewtable creation
> > CREATE VIEW dbo.appsvw AS
> > SELECT TOP 1000 dbo.Positions.posName AS [Position],
> > dbo.Companies.compName
> > AS Company, dbo.Applications.appDate AS [Date],
> > dbo.Applications.appNotes AS Notes,
> > dbo.Applications.appID AS ID
> > FROM
> > dbo.Companies INNER JOIN
> > dbo.Applications ON
> > dbo.Companies.compID = dbo.Applications.appCompany INNER JOIN
> > dbo.Positions ON
> > dbo.Applications.appPosition = dbo.Positions.posID
> > ORDER BY dbo.Applications.appID
> >
> > TIA
> > --
> >
> > Patrick Sullivan, AA-BA, BA-IT
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Powerpoint display is cut off on data projector display. David-DEC Microsoft Powerpoint 1 16th Jan 2008 04:09 PM
Wrong display of smallmoney data in a linked SQL Server table =?Utf-8?B?TWFyY3VzSw==?= Microsoft Access External Data 1 6th Jan 2006 02:39 AM
Retrieve GAL data from exchange server 5.5 and display in asp.net (.aspx) page krushn@gmail.com Microsoft Dot NET 0 4th Oct 2005 08:08 PM
"?" display in sql server table when transfer data from access tab =?Utf-8?B?QW1pcg==?= Microsoft Access External Data 0 1st Mar 2005 02:19 PM
using Crystal Reports to display data in my dataset correctly (display the data I selected instead of all the data in table) JK Microsoft C# .NET 1 6th Sep 2003 10:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:21 PM.