Results 1 to 7 of 7

Thread: [RESOLVED] Help me with this connection

  1. #1

    Thread Starter
    Addicted Member o0yuna0o's Avatar
    Join Date
    Mar 2006
    Posts
    172

    Resolved [RESOLVED] Help me with this connection

    VB Code:
    1. Dim db As ADODB.Connection
    2. Dim rs As ADODB.Recordset
    3. Dim dteFormat As StdDataFormat
    4. Dim strSQL As String
    5.  
    6. Set db = New ADODB.Connection
    7.  
    8. 'A hierarchical recordset requires the MSDataShape provider.
    9. [B]db.Open "provider=msdatashape;data provider=sqloledb;data source=handel;" _
    10.       & "initial catalog=northwind;integrated security=sspi"[/B]
    11. Set rs = New ADODB.Recordset
    12.  
    13. strSQL = "Shape {Select CustomerId, CompanyName From Customers} " _
    14.     & "Append ({Select CustomerId, OrderId, OrderDate From Orders} As Orders " _
    15.     & "Relate CustomerId To CustomerId)"
    16.  
    17. rs.Open strSQL, db, adOpenStatic, adLockReadOnly
    18. Set rs.ActiveConnection = Nothing
    19.  
    20. 'Group header section - contains 1 unbound rptTextBox control
    21. DataReport1.Sections("Section6").Controls(1).DataField = "CompanyName"
    22.  
    23. 'details section - contains 2 unbound rptTextBox control
    24. With DataReport1.Sections("Section1").Controls
    25.     .Item(1).DataMember = "Orders" 'indicate the field is from the Child recordset
    26.     .Item(1).DataField = "OrderId"
    27.    
    28.     Set dteFormat = New StdDataFormat
    29.     dteFormat.Type = fmtCustom
    30.     dteFormat.Format = "dd-MMM-yyyy"
    31.  
    32.     .Item(2).DataMember = "Orders"
    33.     .Item(2).DataField = "OrderDate"
    34.     Set .Item(2).DataFormat = dteFormat
    35. End With
    36.  
    37. 'Group Footer section - contains 1 unbound rptFunction control
    38. 'indicates the total # of orders per customer group
    39. With DataReport1.Sections("Section7").Controls
    40.     .Item(1).DataMember = "Orders"
    41.     .Item(1).DataField = "OrderId"
    42.     .Item(1).FunctionType = rptFuncRCnt
    43. End With
    44.  
    45. DataReport1.Sections("Section7").ForcePageBreak = rptPageBreakAfter
    46.  
    47. Set DataReport1.DataSource = rs
    48. DataReport1.Show
    49.  
    50. Set dteFormat = Nothing
    51. Set rs = Nothing
    52. db.Close
    53. Set db = Nothing

    I found this here in Reporting... forum

    I want to know what is the proper way to connect a .MDB or MS Access 2000 file

  2. #2
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    Re: Help me with this connection

    The connection string to connect to an Access db would look something like this

    Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Microsoft Visual Studio\VB98\NWIND_2003.MDB;Persist Security Info=False

  3. #3
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Help me with this connection

    If you will also be using the shape query then you will need to differentiate provider and data provider like in your sample, since provider needs to be declared as msdatashape.

  4. #4

    Thread Starter
    Addicted Member o0yuna0o's Avatar
    Join Date
    Mar 2006
    Posts
    172

    Re: Help me with this connection

    Quote Originally Posted by MarkT
    The connection string to connect to an Access db would look something like this

    Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Microsoft Visual Studio\VB98\NWIND_2003.MDB;Persist Security Info=False

    Hi, What i need is the dataShape Provider.

  5. #5
    Fanatic Member eSPiYa's Avatar
    Join Date
    Jun 2006
    Location
    in our house
    Posts
    751

    Re: Help me with this connection

    I'm not good in connection strings, I'm using some wizards then copy & paste them.
    I know this is not recommended but try if you want. I'm using ADODataControl's(I'm not sure w/ the name but maybe it looks like it) Connection Builder.

    I'm using this one too: "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;User Id=admin;Password=;"

    Here is a sample:
    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & app.path &"\mydb.mdb;User Id=admin;Password=;"
    [Note]Your MSAccess database must be in same directory w/ your application/executable.

    This work w/ Crystal Reports(Tested for several years) and Datareports(My former classmates used them and I see the connectionstring is same with mine but haven't used Datareports).

  6. #6

    Thread Starter
    Addicted Member o0yuna0o's Avatar
    Join Date
    Mar 2006
    Posts
    172

    Re: Help me with this connection

    Quote Originally Posted by eSPiYa
    I'm not good in connection strings, I'm using some wizards then copy & paste them.
    I know this is not recommended but try if you want. I'm using ADODataControl's(I'm not sure w/ the name but maybe it looks like it) Connection Builder.

    I'm using this one too: "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;User Id=admin;Password=;"

    Here is a sample:
    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & app.path &"\mydb.mdb;User Id=admin;Password=;"
    [Note]Your MSAccess database must be in same directory w/ your application/executable.

    This work w/ Crystal Reports(Tested for several years) and Datareports(My former classmates used them and I see the connectionstring is same with mine but haven't used Datareports).
    Hi thanks for your answer but im looking for datashape provider

  7. #7
    Fanatic Member eSPiYa's Avatar
    Join Date
    Jun 2006
    Location
    in our house
    Posts
    751

    Re: Help me with this connection

    How about this:
    "Provider=MSDataShape;Data Provider=Microsoft.Jet.OLEDB.4.0;Dbq=c:\somepath\mydb.mdb;User ID=myUsername;Password=myPassword"

    I haven't tested it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width