Viewing Navision data using ASP

NaveenReddyNaveenReddy Member Posts: 53
Hi guys
Did anyone able to connect to navision using ASP connection strings ?

I used using the DSN but it doesn't work.

For connecting to access i used this code ::
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:\Customers.mdb"
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "Select * from Customer", conn

For connecting to navision i tried to use the same code with some modification, but i am not sure what to use for provider. do anyone know what should i use for provider.

Comments

  • mstallmannmstallmann Member Posts: 138
    I don't have ODBC installed on this machine right now, so I don't know the string expression you need to enter.

    However, you might have an easier time creating a system dsn, the connection string is much easier. First create a machine DSN named Navision, then use the following code:


    Dim strSQL, strDSN
    Dim i
    strSQL="Select * from Customer"
    strDSN="DSN=Navision"
    Set rs=Server.CreateObject("ADODB.Recordset")
    rs.Open strSQL,strDSN
    Response.Write "<TABLE BORDER=1>"
    `Write out Field Names
    Response.Write "<TR>"
    For i=0 to rs.fields.count-1
    Response.Write "<TH>"+rs(i).Name+"</TH>"
    Next
    Response.Write "</TR>"
    `Write out Data
    Do while not rs.eof
    Response.Write "<TR>
    For i=0 to rs.fields.count-1
    Response.Write "<TD>
    Response.Write rs(i)
    Response.Write "</TD>
    Next
    Response.Write "</TR>
    rs.movenext
    Loop
    Response.Write "</TABLE>"

    I didn't test it, but this should work.

    Mike
  • FabermanFaberman Member Posts: 24
    Hi.

    With regard to Mstallmann -

    I have been looking for a solution to this problem and found your post.
    I tried what you suggested, and got error messages referring to problems with the adovbs.inc file.

    Have you had any joy with this? Have you found an alternative way to do it?

    If so, please help. ](*,)
  • mstallmannmstallmann Member Posts: 138
    It has been a while since I have done ASP programming, but if my memory serves me right, the adovbs.inc file is just a file that includes a bunch of definitions, declarations, etc. to make development a little bit easier in ASP. Correct?

    What error are you getting? I am assuming that it would have nothing to do with the adovbs.inc file, unless you made changes to it. I think you should be able to run my code without including the adovbs.inc. Try removing the reference to it at the top and see if your code runs.

    Mike
  • FabermanFaberman Member Posts: 24
    Thanks for coming back to me.

    I have removed the include (adovbc.inc).
    I placed a form on a page with a button. The form's action is the asp page making the connection to the Customer table in Navision.
    When the button is clicked, execution moves to the connection page, though it appears blank in the browser.

    No error messages, though.
  • FabermanFaberman Member Posts: 24
    Hi (again) -

    I've just run the connection again, with the following error :

    Error Type:
    Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
    [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
    /Navision.asp, line 11

    strSQL="Select * from Customer"
    strDSN="DSN=Navision"

    Set rs=Server.CreateObject("ADODB.Recordset")
    rs.Open strSQL,strDSN <
    Line 11
  • ChristophChristoph Member Posts: 9
    you will need to registrate your DSN (you called it 'Navison') in the ODBC of your system / system where the code is running..

    read more in the codbc documentation on navision cd..
  • mstallmannmstallmann Member Posts: 138
    Christoph is right...did you create the System DSN?

    Mike
  • FabermanFaberman Member Posts: 24
    Hi all.

    I have re-installed C/ODBC, created and configured a system DSN and I have made changes to my code.
    I have been able to access and display data from Navision. :D

    I have tried some recordset functions with the retrieved data and found that certain recordset properties don't sit well i.e.

    Using rs.Open strSQL, ocon, 3, 1 to open a recordset

    Then rs.AbsolutePage = var where car is a variable

    Results in the following error message :

    ADODB.Recordset (0x800A0CB3)
    Current Recordset does not support bookmarks. This may be a limitation of the provider or of the selected cursortype.

    I have changed CursorType and LockType parameters without change.
    But this is a different issue from that we have been discussing.

    Thank you all for your responses. =D>
  • mstallmannmstallmann Member Posts: 138
    I haven't encountered those errors when using ASP, but in ASP.net there were many things that could not be accomplished using the Nav ODBC driver. I spoke with a developer at MS about this, and basically there was a lot of functionality that was not built into the Nav ODBC driver.

    He told me they were planning on making the driver .net compatible with 4.0, but I haven't followed up on that.

    Basically, they didn't provide interfaces for much of the MS funcionality in the driver, and it is hit and miss. I think thier plann was just to provide enough for office integration, etc. and were not planning on developers getting down and dirty with it.

    Another option is to build you own object that basically takes the recordset provided by the Nav ODBC driver and then create a new recordset, populate it with the data and pass it on to the client application. This is very resource intensive, but it would make the functionality transparent to other developers.

    One more option is to try out the OCX. I have not gone that route, but it may be worth a shot.

    Mike
  • stuarthstuarth Member Posts: 16
    Here is some code that worked for me in asp, however you will need the Navision ODBC driver. this worked on C/ODBC 3.01, and N/ODBC.


    dim ADOconn, ADOrs, sqlstr
    sqlstr="Select * From Currency"
    set ADOconn = Server.CreateObject("ADODB.Connection")
    ADOconn.Open "NavisionSystemDSN"
    set ADOrs = ADOconn.execute(sqlstr)
    if ADOrs.BOF and ADOrs.EOF then ' Query didn't return any records.
    Response.Write("No Records.")
    else
    ADOrs.MoveFirst
    Do While Not ADOrs.EOF
    Response.Write((ADOrs("Code")) & " " _
    & (ADOrs("Last Date Modified")) & "<br>")
    ADOrs.MoveNext
    Loop
    Response.Write("<p>End of data.")
    end if
    ADOrs.close
    set ADOrs = nothing


    Hope this helps.
    :wink:
  • kubachojkubachoj Member Posts: 10
    Maybe else my problem
    Is here:
    http://www.mibuso.com/forum/viewtopic.php?t=8063

    Regards
  • CtrlShiftF11CtrlShiftF11 Member Posts: 29
    or you could use Macromedia ColdFusion and write one line to connect...
    <cfquery name="YourQueryNameHere" datasource="YourDSNHere"
    --SQL Code Here
    </cfquery>
    

    I know that there are a lot of Microsoft freaks in here but ColdFusion is way more rapid when it comes to developing database driven web apps.

    Good Luck!
Sign In or Register to comment.