Vb Data Import Export

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rajaaryan44
    New Member
    • Mar 2007
    • 11

    Vb Data Import Export

    i m using access2003 database for my Project. now i have to import data from another access database with the same table name. can any one please tell me how to import data from another access file using codes.please its urgent
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Use the Update command, I'd have to look, to make sure. Just make sure the table/tables columns you are updating to in one database are also available and in the same sequence in the other. Also, you may consider posting to the Access forum as well, I am not yet an amateur at this, fancy techniques may be found there :-)

    Comment

    • vijaydiwakar
      Contributor
      • Feb 2007
      • 579

      #3
      Originally posted by rajaaryan44
      i m using access2003 database for my Project. now i have to import data from another access database with the same table name. can any one please tell me how to import data from another access file using codes.please its urgent
      see there are two ways to do so
      1. use import facility of Access itself
      2. Make two connections one to retrive date and another to insert this data in other database

      for that open one recordset create Qry according to ur actual database and insert using connection object
      this is the tech. for actual code u've to try it
      I'm able to give it 2 u but i think if u do it by urself then it'll uprise ur confidance
      bbye 'n take care

      Comment

      • rajaaryan44
        New Member
        • Mar 2007
        • 11

        #4
        . i wrote some codes in dao. i created a function : AddTableField

        i m writing it in module so that it can be access from anywhere in the program
        this is the code

        Sub AddTableField(p tdfTableDef As DAO.TableDef, pstrFieldName As String, pintDatatype As Integer, Optional pintSize As Integer, Optional pblnFixedLength As Boolean, Optional pblnAutoIncreme nt As Boolean, Optional pblnAllowZeroLe ngth As Boolean, Optional pblnRequired As Boolean, Optional pstrValidationT ext As String, Optional pstrValidationR ule As String, Optional pvarDefaultValu e As Variant)
        Dim fldX As DAO.Field
        Dim intSize As Integer

        Set fldX = ptdfTableDef.Cr eateField()

        fldX.OrdinalPos ition = ptdfTableDef.Fi elds.Count

        fldX.Name = pstrFieldName
        fldX.Type = pintDatatype

        If Not IsMissing(pblnA llowZeroLength) Then
        If pintDatatype = dbText And pintSize > 0 Then
        fldX.Size = pintSize
        Else
        fldX.Size = GetFieldSize(pi ntDatatype)
        End If
        Else
        fldX.Size = GetFieldSize(pi ntDatatype)
        End If

        If fldX.Type = dbLong Then
        If pblnAutoIncreme nt = True Then
        fldX.Attributes = fldX.Attributes Or dbAutoIncrField
        End If
        End If

        If fldX.Type = dbText Or fldX.Type = dbMemo Then
        fldX.AllowZeroL ength = True
        End If

        If Not IsMissing(pblnR equired) Then
        fldX.Required = pblnRequired
        End If

        If Not IsMissing(pstrV alidationText) Then
        fldX.Validation Text = pstrValidationT ext
        End If

        If Not IsMissing(pstrV alidationRule) Then
        fldX.Validation Rule = pstrValidationR ule
        End If

        If Not IsMissing(pvarD efaultValue) Then
        fldX.DefaultVal ue = pvarDefaultValu e
        End If

        ptdfTableDef.Fi elds.Append fldX

        End Sub
        .

        still i cannot get the transfer done

        Comment

        • rajaaryan44
          New Member
          • Mar 2007
          • 11

          #5
          . i wrote some codes in dao. i created a function : AddTableField

          i m writing it in module so that it can be access from anywhere in the program
          this is the code
          Code:
          .
          Sub AddTableField(ptdfTableDef As DAO.TableDef, pstrFieldName As String, pintDatatype As Integer, Optional pintSize As Integer, Optional pblnFixedLength As Boolean, Optional pblnAutoIncrement As Boolean, Optional pblnAllowZeroLength As Boolean, Optional pblnRequired As Boolean, Optional pstrValidationText As String, Optional pstrValidationRule As String, Optional pvarDefaultValue As Variant)
          Dim fldX As DAO.Field
          Dim intSize As Integer
          
          Set fldX = ptdfTableDef.CreateField()
          
          fldX.OrdinalPosition = ptdfTableDef.Fields.Count
          
          fldX.Name = pstrFieldName
          fldX.Type = pintDatatype
          
          If Not IsMissing(pblnAllowZeroLength) Then
          If pintDatatype = dbText And pintSize > 0 Then
          fldX.Size = pintSize
          Else
          fldX.Size = GetFieldSize(pintDatatype)
          End If
          Else
          fldX.Size = GetFieldSize(pintDatatype)
          End If
          
          If fldX.Type = dbLong Then
          If pblnAutoIncrement = True Then
          fldX.Attributes = fldX.Attributes Or dbAutoIncrField
          End If
          End If
          
          If fldX.Type = dbText Or fldX.Type = dbMemo Then
          fldX.AllowZeroLength = True
          End If
          
          If Not IsMissing(pblnRequired) Then
          fldX.Required = pblnRequired
          End If
          
          If Not IsMissing(pstrValidationText) Then
          fldX.ValidationText = pstrValidationText
          End If
          
          If Not IsMissing(pstrValidationRule) Then
          fldX.ValidationRule = pstrValidationRule
          End If
          
          If Not IsMissing(pvarDefaultValue) Then
          fldX.DefaultValue = pvarDefaultValue
          End If
          
          ptdfTableDef.Fields.Append fldX
          
          End Sub
          .

          still i cannot get the transfer done

          Comment

          Working...