Microsoft Access Query and VB.Net function.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • shapper

    #1

    Microsoft Access Query and VB.Net function.

    Hello,

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

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

    SELECT content_localiz ed.content_html
    FROM content INNER JOIN content_localiz ed ON content.content _id =
    content_localiz ed.content_id
    WHERE (((content.cont ent_page)=[@Page]) AND
    ((content.conte nt_name)=[@Name]) AND
    ((content_local ized.content_cu lture)=[@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_localiz ed.content_html .

    My function code is as follows:

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

    ' Set Connection
    Dim connectionStrin g As String =
    ConfigurationMa nager.Connectio nStrings(_Conne ctionString).Co nnectionString
    Dim connection As New
    System.Data.Ole Db.OleDbConnect ion(connectionS tring)

    ' Set Command
    Dim command As New System.Data.Ole Db.OleDbCommand
    With command
    .CommandText = "EXECUTE content_SELECT"
    .Connection = connection
    .CommandType = CommandType.Tex t
    End With

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

    ' Execute the Command
    connection.Open ()
    Dim contentHtml As OleDb.OleDbData Reader = command.Execute Reader
    If contentHtml.Rea d Then
    Return contentHtml.Ite m("content_html ").ToString ()
    Else
    Return "Something is Wrong" ***
    End If
    contentHtml.Clo se()
    connection.Clos e()

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

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

    I tried everything I could think of to solve this problem.

    Could someone, please, help me out?

    Thanks,
    Miguel

Working...