Very basic question
-
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!. -
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!.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 -
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 Gandhijdunlap wrote: Did you add Microsoft ActiveX Data Objects to your references? Ahhh!! I didnt do it... Thanks.... I was born intelligent
Education ruined me!.