Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Very basic question

Very basic question

Scheduled Pinned Locked Moved Visual Basic
questiondatabasehelplearning
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sarvesvara BVKS Dasa
    wrote on last edited by
    #1

    Hi... I am a beginer to VB.. and a basic question.... Any code or snippet for accessing MS access database from VB, on a button click action... I tried this.... Private Sub Command1_Click() Dim DBCon As ADODB.Connection Dim rsTemp As ADODB.Recordset Dim objMail Set DBCon = New ADODB.Connection Set rsTemp = New ADODB.Recordset On Error GoTo errhandle DBCon.Open dsn.Text, username.Text, password.Text rsTemp.CursorLocation = adUseClient rsTemp.Open SQLstr.Text, DBCon, adOpenForwardOnly, adLockReadOnly mailbody = body.Text For i = 1 To CInt(paramnum.Text) mailbody = Replace(mailbody, "[x" & i & "]", rsTemp.Fields("x" & i)) Next i MsgBox "From = " & from_txt.Text & Chr(10) & Chr(13) & _ "To = " & rsTemp("toemail") & Chr(10) & Chr(13) & _ "Subject = " & subjfield.Text & Chr(10) & Chr(13) & _ "Body =" & mailbody Exit Sub errhandle: MsgBox Err.Description End Sub But it says.... Compile Error, User defined type not defined in the very first line of the code. Should I make/modify any configurations?? Thanks I was born intelligent
    Education ruined me!.

    J 1 Reply Last reply
    0
    • S Sarvesvara BVKS Dasa

      Hi... I am a beginer to VB.. and a basic question.... Any code or snippet for accessing MS access database from VB, on a button click action... I tried this.... Private Sub Command1_Click() Dim DBCon As ADODB.Connection Dim rsTemp As ADODB.Recordset Dim objMail Set DBCon = New ADODB.Connection Set rsTemp = New ADODB.Recordset On Error GoTo errhandle DBCon.Open dsn.Text, username.Text, password.Text rsTemp.CursorLocation = adUseClient rsTemp.Open SQLstr.Text, DBCon, adOpenForwardOnly, adLockReadOnly mailbody = body.Text For i = 1 To CInt(paramnum.Text) mailbody = Replace(mailbody, "[x" & i & "]", rsTemp.Fields("x" & i)) Next i MsgBox "From = " & from_txt.Text & Chr(10) & Chr(13) & _ "To = " & rsTemp("toemail") & Chr(10) & Chr(13) & _ "Subject = " & subjfield.Text & Chr(10) & Chr(13) & _ "Body =" & mailbody Exit Sub errhandle: MsgBox Err.Description End Sub But it says.... Compile Error, User defined type not defined in the very first line of the code. Should I make/modify any configurations?? Thanks I was born intelligent
      Education ruined me!.

      J Offline
      J Offline
      J Dunlap
      wrote on last edited by
      #2

      Did you add Microsoft ActiveX Data Objects to your references? To do this, Click Project | References on the menu, and check the check box beside it in the dialog box.
      Do unto others as you would have them do unto you - Jesus
      An eye for an eye only makes the whole world blind - Mahatma Gandhi

      S 1 Reply Last reply
      0
      • J J Dunlap

        Did you add Microsoft ActiveX Data Objects to your references? To do this, Click Project | References on the menu, and check the check box beside it in the dialog box.
        Do unto others as you would have them do unto you - Jesus
        An eye for an eye only makes the whole world blind - Mahatma Gandhi

        S Offline
        S Offline
        Sarvesvara BVKS Dasa
        wrote on last edited by
        #3

        jdunlap wrote: Did you add Microsoft ActiveX Data Objects to your references? Ahhh!! I didnt do it... Thanks.... I was born intelligent
        Education ruined me!.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups