Click to See Complete Forum and Search --> : VB Application


meeta21
August 5th, 2001, 03:17 PM
Hi There, I'm learning VB. I'm trying to write an application in Vb. To Add a record I've a code written as below. I'm not sure how exactly to write(insert) into database. Any help would be greatly appreciated. Thanks in advance.

Private Sub CmdSubmit_Click()
DataGrid1.Visible = True
Dim ctg As String
Dim des As String
Dim amount As Currency
Dim exdate As Date
Dim paymethod As String, ename As String
Dim checknum As Integer
Dim sqlExp As String


If (IsNumeric(txtAmount.Text)) Then

ctg = CmbCtg
des = txtDes.Text
exdate = txtDate.Text
paymethod = CmbPaymentMethod
ename = txtEntityName.Text
checknum = txtCheckNum.Text
amount = CInt(txtAmount.Text)

sqlExp = "INSERT INTO tblExpense ( Exp_Ctg, Exp_Description, Exp_Date, Exp_PaymentMethod, Exp_EntityName, Exp_Checknum, Exp_Amount )" + _
"Values ('" & ctg & "','" & des & "','" & exdate & "','" & paymethod & "','" & ename & "','" & checknum & "'," & amount & ")"
HOW DO i EXCUTE THIS QUERY????????
Adodc2.Refresh
DataGrid1.Refresh

End Sub

Tower
August 5th, 2001, 07:39 PM
Dim adoCommand as new ADODB.Command

With adoCommand
.ActiveConnection = Adodc2
.CommandText = sqlExp
.CommandType = adCmdText
.Execute
End With