473,386 Members | 2,078 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Column 'link_url' does not belong to table links.

I have a simple Stored Procedure with multiple select statements..doing
select * from links for example.
I created a DataTable and then fill the tables
But the first dtTemplate DataTable doesn't give the error but the links
does!
I get the error on this LINE(when looping):-

PageLinks.Text = PageLinks.Text & dtLinks.Rows(iLoop)("link_url")
cmdAccess.CommandType = CommandType.StoredProcedure
cmdAccess.CommandText = "mystocprocedure"

Dim daTemplate As SqlDataAdapter = New SqlDataAdapter(cmdAccess)
Dim daLinks As SqlDataAdapter = New
SqlDataAdapter(cmdAccess)
Dim daCategory As SqlDataAdapter = New
SqlDataAdapter(cmdAccess)

Dim dsAccess As DataSet = New DataSet
Dim dtTemplate As DataTable = New DataTable
Dim dtLinks As DataTable = New DataTable
Dim dtCategory As DataTable = New DataTable
'filling DataSet with links table
daLinks.Fill(dsAccess, "links")
dtLinks = dsAccess.Tables("links")

dtLinksCount = dtLinks.Rows.Count
PageLinks.Text = ""

While iLoop < dtLinksCount
PageLinks.Text = PageLinks.Text & "<a href="
PageLinks.Text = PageLinks.Text &
dtLinks.Rows(iLoop)("link_url")
PageLinks.Text = PageLinks.Text & ">"
PageLinks.Text = PageLinks.Text &
dtLinks.Rows(iLoop)("link_text")
PageLinks.Text = PageLinks.Text & "</a>"

If iLoop < dtLinksCount - 1 Then
PageLinks.Text = PageLinks.Text & " | "
End If
System.Math.Min(System.Threading.Interlocked.Incre ment(iLoop), iLoop -
1)

End While

Any ideas?

*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #1
7 1675
What error do you get?
btw, does the table has that column? Recheck the design..

--
Cheers,
Gaurav Vaish
http://mastergaurav.blogspot.com
http://mastergaurav.org
-------------------------

Nov 19 '05 #2
Thx Gaurav for the response!
I get the Error :- Column 'link_url' does not belong to table links
The column exists for sure.

If i do :-

string ssLinks = "Select * From links";
SqlDataAdapter daLinks = new SqlDataAdapter(ssLinks, dcAccess);
DataTable dtLinks = new DataTable();

I get the desired result but when i use stored procedure i get the
error.
I don't want to use string for calling my sql statements.
But i think the problem is that my select satements in the stored
procedure doesn't feed the DataTable correctly
when i LOOP through the records
Any workarounds?


*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #3
Hi Patrick,

If your SP has multiple select queries, you don't need to
multi-fill dataset. Only one SqlDataAdapter.Fill(dataset)
call will fill multi-tables in the dataset.

It's similar to following example:

Dim dap As New SqlDataAdapter("Select * From Table1;
Select * From Table2", CONNECTION_STRING)
Dim ds As New DataSet
dap.Fill(ds)

Two datatables are filled to the dataset.

HTH

Elton Wang
el********@hotmail.com
-----Original Message-----
I have a simple Stored Procedure with multiple select statements..doingselect * from links for example.
I created a DataTable and then fill the tables
But the first dtTemplate DataTable doesn't give the error but the linksdoes!
I get the error on this LINE(when looping):-

PageLinks.Text = PageLinks.Text & dtLinks.Rows(iLoop) ("link_url")

cmdAccess.CommandType = CommandType.StoredProcedure
cmdAccess.CommandText = "mystocprocedure"

Dim daTemplate As SqlDataAdapter = New SqlDataAdapter (cmdAccess) Dim daLinks As SqlDataAdapter = New
SqlDataAdapter(cmdAccess)
Dim daCategory As SqlDataAdapter = New
SqlDataAdapter(cmdAccess)

Dim dsAccess As DataSet = New DataSet
Dim dtTemplate As DataTable = New DataTable
Dim dtLinks As DataTable = New DataTable
Dim dtCategory As DataTable = New DataTable
'filling DataSet with links table
daLinks.Fill(dsAccess, "links")
dtLinks = dsAccess.Tables("links")

dtLinksCount = dtLinks.Rows.Count
PageLinks.Text = ""

While iLoop < dtLinksCount
PageLinks.Text = PageLinks.Text & "<a href=" PageLinks.Text = PageLinks.Text &
dtLinks.Rows(iLoop)("link_url")
PageLinks.Text = PageLinks.Text & ">"
PageLinks.Text = PageLinks.Text &
dtLinks.Rows(iLoop)("link_text")
PageLinks.Text = PageLinks.Text & "</a>"

If iLoop < dtLinksCount - 1 Then
PageLinks.Text = PageLinks.Text & " | " End If
System.Math.Min(System.Threading.Interlocked.Incr ement (iLoop), iLoop -1)

End While

Any ideas?

*** Sent via Developersdex http://www.developersdex.com ***.

Nov 19 '05 #4
Thx for the reply Elton

This is what 'm trying to do:-

Tried using one DataAdapter but i still get Error on line:-

PageLinks.Text = PageLinks.Text & dtLinks.Rows(iLoop)("link_url")
Code below
-------------
Dim cmdAccess As New SqlCommand("webpage", dcAccess)
cmdAccess.CommandType = CommandType.StoredProcedure

Dim daTemplate As SqlDataAdapter = New SqlDataAdapter(cmdAccess)

Dim dsAccess As DataSet = New DataSet
Dim dtTemplate As DataTable = New DataTable
Dim dtLinks As DataTable = New DataTable
Dim dtCategory As DataTable = New DataTable
Dim dtPage As DataTable = New DataTable

Dim dtLinksCount As Integer
Dim dtCategoryCount As Integer
dcAccess.Open()
daTemplate.Fill(dsAccess, "templates")
dtTemplate = dsAccess.Tables("templates")

PageHeader.Text =
dtTemplate.Rows(0)("template_header").ToString
PageFooter.Text =
dtTemplate.Rows(0)("template_footer").ToString

daTemplate.Fill(dsAccess, "links")

dtLinks = dsAccess.Tables("links")

dtLinksCount = dtLinks.Rows.Count
PageLinks.Text = ""
Dim iLoop As Integer
iLoop = 0

'Pulls out the category TOP links from the Database by
looping through dtLinks

While iLoop < dtLinksCount
PageLinks.Text = PageLinks.Text & "<a href="
PageLinks.Text = PageLinks.Text &
dtLinks.Rows(iLoop)("link_url")
PageLinks.Text = PageLinks.Text & ">"
PageLinks.Text = PageLinks.Text &
dtLinks.Rows(iLoop)("link_text")
PageLinks.Text = PageLinks.Text & "</a>"

If iLoop < dtLinksCount - 1 Then
PageLinks.Text = PageLinks.Text & " | "
End If
System.Math.Min(System.Threading.Interlocked.Incre ment(iLoop), iLoop -
1)

End While

daTemplate.Fill(dsAccess, "category")

dtCategory = dsAccess.Tables("category")
dtCategoryCount = dtCategory.Rows.Count
PageCategory.Text = ""
iLoop = 0

While iLoop < dtCategoryCount
PageCategory.Text = PageCategory.Text & "<a href="
PageCategory.Text = PageCategory.Text &
dtCategory.Rows(iLoop)("category_url")
PageCategory.Text = PageCategory.Text & ">"
PageCategory.Text = PageCategory.Text &
dtCategory.Rows(iLoop)("category_text")
PageCategory.Text = PageCategory.Text & "</a><br>"

System.Math.Min(System.Threading.Interlocked.Incre ment(iLoop), iLoop -
1)

End While

'Displaying the Category Headers
'daPage.Fill(dsAccess, "pages")

daTemplate.Fill(dsAccess, "pages")

dtPage = dsAccess.Tables("pages")
PageContent.Text = ""
PageContent.Text = PageContent.Text & "<center><b>"
PageContent.Text = PageContent.Text &
dtPage.Rows(0)("page_title")
PageContent.Text = PageContent.Text & "<br>"
PageContent.Text = PageContent.Text &
dtPage.Rows(0)("page_subtitle")
PageContent.Text = PageContent.Text & "</b><br></center>"
PageContent.Text = PageContent.Text &
dtPage.Rows(0)("page_text")
If Not (Request.QueryString("category") Is Nothing) Then
Dim ssCatPage As String = "Select page_id, page_title,
page_subtitle From pages Where page_category = " &
Request.QueryString("category")
Dim daCatPage As SqlDataAdapter = New
SqlDataAdapter(ssCatPage, dcAccess)
Dim dtCatPage As DataTable = New DataTable
Dim dtCatPageCount As Integer

daCatPage.Fill(dsAccess, "catpages")
dtCatPage = dsAccess.Tables("catpages")
dtCatPageCount = dtCatPage.Rows.Count

iLoop = 0

'Displaying Content in the inner page
While iLoop < dtCatPageCount
PageContent.Text = PageContent.Text & "<p>"
PageContent.Text = PageContent.Text & "<a
href=default.aspx?page="
PageContent.Text = PageContent.Text &
dtCatPage.Rows(iLoop)("page_id")
PageContent.Text = PageContent.Text & ">"
PageContent.Text = PageContent.Text &
dtCatPage.Rows(iLoop)("page_title")
PageContent.Text = PageContent.Text & "</a><br>"
PageContent.Text = PageContent.Text &
dtCatPage.Rows(iLoop)("page_subtitle")
PageContent.Text = PageContent.Text & "</p>"

System.Math.Min(System.Threading.Interlocked.Incre ment(iLoop), iLoop -
1)
End While
End If

*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #5
And Elton the simple store proc looks like this:-
CREATE PROCEDURE dbo.webpage
AS
Select template_id,template_header,template_footer from templates
Select link_id,link_text,link_url from links
Select category_id,category_text,category_url from category
Select page_id,page_category,page_title,page_subtitle,pag e_text from
pages
RETURN
GO


*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #6
As I mentioned, you only need fill dataset once:

Dim cmdAccess As New SqlCommand("webpage", dcAccess)
cmdAccess.CommandType = CommandType.StoredProcedure

Dim daTemplate As SqlDataAdapter = New SqlDataAdapter(cmdAccess)

Dim dsAccess As DataSet = New DataSet
Dim dtTemplate As DataTable = New DataTable
Dim dtLinks As DataTable = New DataTable
Dim dtCategory As DataTable = New DataTable
Dim dtPage As DataTable = New DataTable
daTemplate.Fill(dsAccess)
' It fills templates, links, category, pages datatable in one time
' Then you can refer to these tables by
dtTemplate = dsAccess.Tables(0)
dtTemplate.TableName = "templates"

dtLinks = dsAccess.Tables(1)
dtLinks.TableName = "links"

dtCategory = dsAccess.Tables(2)
dtCategory.TableName = "category"

dtPage = dsAccess.Tables(3)
dtPage.TableName = "pages"
HTH
"Patrick Olurotimi Ige" wrote:
And Elton the simple store proc looks like this:-
CREATE PROCEDURE dbo.webpage
AS
Select template_id,template_header,template_footer from templates
Select link_id,link_text,link_url from links
Select category_id,category_text,category_url from category
Select page_id,page_category,page_title,page_subtitle,pag e_text from
pages
RETURN
GO


*** Sent via Developersdex http://www.developersdex.com ***

Nov 19 '05 #7
Thx for the reply....
I got it working having each Stored Proc to each DataADapter before.
But with this new trick its cool
Thx Elton
*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Holmespundit | last post by:
Stylists... I'm having problems collapsing a column. Specifically, I want to collapse the last column of a table. My initial test with a large data set worked, but I cannot make it work with a...
0
by: mkomasi | last post by:
I am using a datagrid in my form sometimes when a child form of this datagrid form closed an exception like "Column C does not belong to the table T" was thrown. this exception is rarely...
5
by: Kejpa | last post by:
Hi, How do you write a Rowfilter for a boolean column? col1=true col1='true' col1= 1 col1= -1 Will all render an exception: Column 'col1' does not belong to table Test. Any thoughts?
10
by: Nick | last post by:
Hello, Please pardon my ignorance as I'm sure this is easy to do. I have a datagrid where I want to let the user delete columns. I added a context menu to the datagrid that has a delete option....
0
by: Mike | last post by:
We are using .NET 2.0 and intermittently egt the following errors on almost all our web pages. The error is not repoducable and cycling the worker process seems to temporarily fix the problems. ...
4
by: Mike | last post by:
We are using .NET 2.0 and intermittently egt the following errors on almost all our web pages. The error is not repoducable and cycling the worker process seems to temporarily fix the problems. ...
1
by: shil | last post by:
Hi all, updating SQL database with the data.I'm stuck with an issue. One of the XML file from the list don't have a node mentioned. For example almost all XML files structure is like this ...
2
by: Ronald S. Cook | last post by:
In the code below, I get a runtime error where indicated. The error is: "Column 'TICKETNO' does not belong to table TICKET_DEDUCTIONS." If I put a breakpoint on that line (so not yet executed)...
1
by: majidkorai | last post by:
Hey Guyz I am having problem when i read the data from a datareader into a data table. The whole scenario is this that I want to read data from two diffrent databases, the table strcutre is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.