Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Query. Can't Execute

Reply
Thread Tools

Query. Can't Execute

 
 
Shapper
Guest
Posts: n/a
 
      09-14-2006
Hello,

I have the tables content and content_localized in a Microsoft Access
database.

I created a Query in my Microsoft Access database named
"content_SELECT":

SELECT content_localized.content_html
FROM content INNER JOIN content_localized ON content.content_id =
content_localized.content_id
WHERE (((content.content_page)=[@Page]) AND
((content.content_name)=[@Name]) AND
((content_localized.content_culture)=[@Culture]));

I tested the Query inside Microsoft Access and it worked fine returning
the expected record.

On my Asp.Net 2.0 web site I created a function which should execute
the Query "content_SELECT" and return value on field
content_localized.content_html.

I tryied everything, I could think of, to make this work but I had no
success.

My function code is as follows:

---------------------------------------------------------------------------------
Public Function Load()

' Set Connection
Dim connectionString As String =
ConfigurationManager.ConnectionStrings(_Connection String).ConnectionString
Dim connection As New
System.Data.OleDb.OleDbConnection(connectionString )

' Set Command
Dim command As New System.Data.OleDb.OleDbCommand
With command
.CommandText = "EXECUTE content_SELECT"
.Connection = connection
.CommandType = CommandType.Text
End With

' Add Parameters
With command.Parameters
.Add(New OleDb.OleDbParameter("[@Culture]", "pt-PT"))
.Add(New OleDb.OleDbParameter("[@Page]", "Default.aspx"))
.Add(New OleDb.OleDbParameter("[@Name]", "Newsletter"))
End With

' Execute the Command
connection.Open()
Dim contentHtml As OleDb.OleDbDataReader = command.ExecuteReader
If contentHtml.Read Then
Return contentHtml.Item("content_html").ToString()
Else
Return "Something is Wrong" ***
End If
contentHtml.Close()
connection.Close()

End Function
---------------------------------------------------------------------------------

My page doesn't display any error but the function returns the string
"Something is Wrong" from my code line ***

Could someone, please, help me out?

Thanks,
Miguel

 
Reply With Quote
 
 
 
 
Hans Kesting
Guest
Posts: n/a
 
      09-14-2006
> Hello,
>
> I have the tables content and content_localized in a Microsoft Access
> database.
>
> I created a Query in my Microsoft Access database named
> "content_SELECT":
>
> SELECT content_localized.content_html
> FROM content INNER JOIN content_localized ON content.content_id =
> content_localized.content_id
> WHERE (((content.content_page)=[@Page]) AND
> ((content.content_name)=[@Name]) AND
> ((content_localized.content_culture)=[@Culture]));
>
> I tested the Query inside Microsoft Access and it worked fine returning
> the expected record.
>
> On my Asp.Net 2.0 web site I created a function which should execute
> the Query "content_SELECT" and return value on field
> content_localized.content_html.
>
> I tryied everything, I could think of, to make this work but I had no
> success.
>
> My function code is as follows:
>
> ---------------------------------------------------------------------------------
> Public Function Load()
>
> ' Set Connection
> Dim connectionString As String =
> ConfigurationManager.ConnectionStrings(_Connection String).ConnectionString
> Dim connection As New
> System.Data.OleDb.OleDbConnection(connectionString )
>
> ' Set Command
> Dim command As New System.Data.OleDb.OleDbCommand
> With command
> .CommandText = "EXECUTE content_SELECT"
> .Connection = connection
> .CommandType = CommandType.Text
> End With
>
> ' Add Parameters
> With command.Parameters
> .Add(New OleDb.OleDbParameter("[@Culture]", "pt-PT"))
> .Add(New OleDb.OleDbParameter("[@Page]", "Default.aspx"))
> .Add(New OleDb.OleDbParameter("[@Name]", "Newsletter"))
> End With
>
> ' Execute the Command
> connection.Open()
> Dim contentHtml As OleDb.OleDbDataReader = command.ExecuteReader
> If contentHtml.Read Then
> Return contentHtml.Item("content_html").ToString()
> Else
> Return "Something is Wrong" ***
> End If
> contentHtml.Close()
> connection.Close()
>
> End Function
> ---------------------------------------------------------------------------------
>
> My page doesn't display any error but the function returns the string
> "Something is Wrong" from my code line ***
>
> Could someone, please, help me out?
>
> Thanks,
> Miguel


Try leaving out the [], as in:
.Add(New OleDb.OleDbParameter("@Name", "Newsletter"))

(reason: the name of the parameter is "@Name", not "[@Name]")

Not that there are some syntax differences between Access used directly
or via OleDb*. One difference I know is wildcards: Access supports "*"
and "?", OleDb needs to have "%" and "_".

Hans Kesting


 
Reply With Quote
 
 
 
 
shapper
Guest
Posts: n/a
 
      09-14-2006

Hans Kesting wrote:
> > Hello,
> >
> > I have the tables content and content_localized in a Microsoft Access
> > database.
> >
> > I created a Query in my Microsoft Access database named
> > "content_SELECT":
> >
> > SELECT content_localized.content_html
> > FROM content INNER JOIN content_localized ON content.content_id =
> > content_localized.content_id
> > WHERE (((content.content_page)=[@Page]) AND
> > ((content.content_name)=[@Name]) AND
> > ((content_localized.content_culture)=[@Culture]));
> >
> > I tested the Query inside Microsoft Access and it worked fine returning
> > the expected record.
> >
> > On my Asp.Net 2.0 web site I created a function which should execute
> > the Query "content_SELECT" and return value on field
> > content_localized.content_html.
> >
> > I tryied everything, I could think of, to make this work but I had no
> > success.
> >
> > My function code is as follows:
> >
> > ---------------------------------------------------------------------------------
> > Public Function Load()
> >
> > ' Set Connection
> > Dim connectionString As String =
> > ConfigurationManager.ConnectionStrings(_Connection String).ConnectionString
> > Dim connection As New
> > System.Data.OleDb.OleDbConnection(connectionString )
> >
> > ' Set Command
> > Dim command As New System.Data.OleDb.OleDbCommand
> > With command
> > .CommandText = "EXECUTE content_SELECT"
> > .Connection = connection
> > .CommandType = CommandType.Text
> > End With
> >
> > ' Add Parameters
> > With command.Parameters
> > .Add(New OleDb.OleDbParameter("[@Culture]", "pt-PT"))
> > .Add(New OleDb.OleDbParameter("[@Page]", "Default.aspx"))
> > .Add(New OleDb.OleDbParameter("[@Name]", "Newsletter"))
> > End With
> >
> > ' Execute the Command
> > connection.Open()
> > Dim contentHtml As OleDb.OleDbDataReader = command.ExecuteReader
> > If contentHtml.Read Then
> > Return contentHtml.Item("content_html").ToString()
> > Else
> > Return "Something is Wrong" ***
> > End If
> > contentHtml.Close()
> > connection.Close()
> >
> > End Function
> > ---------------------------------------------------------------------------------
> >
> > My page doesn't display any error but the function returns the string
> > "Something is Wrong" from my code line ***
> >
> > Could someone, please, help me out?
> >
> > Thanks,
> > Miguel

>
> Try leaving out the [], as in:
> .Add(New OleDb.OleDbParameter("@Name", "Newsletter"))
>
> (reason: the name of the parameter is "@Name", not "[@Name]")
>
> Not that there are some syntax differences between Access used directly
> or via OleDb*. One difference I know is wildcards: Access supports "*"
> and "?", OleDb needs to have "%" and "_".
>
> Hans Kesting


Hello,

I removed the [] and I still have the same problem.
What else should I try?
I have been searching in Google for a solution and I really can't find
the reason why my code is not working.

Thanks,
Miguel

 
Reply With Quote
 
 
 
Reply

Thread Tools

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
create and execute bat file in vb.net Eric Wood ASP .Net 2 07-10-2007 06:48 AM
i am trying to Execute some command Bar Button but doesn't work =?Utf-8?B?ZG9ybGluZw==?= ASP .Net 0 06-23-2005 11:08 PM
Can i execute aspx file in my asp pag with server.execute method(sorry) Savas Ates ASP General 1 08-17-2004 04:52 PM
Re: asp Page events execute twice after PostBack again Tom Vande Stouwe MCSD.net ASP .Net 1 09-03-2003 03:34 PM
aspx Page events execute twice after HTTP POST Lewis ASP .Net 1 08-20-2003 01:46 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57