CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: VB Application

  1. #1
    Join Date
    Aug 2001
    Posts
    2

    VB Application

    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


  2. #2
    Join Date
    May 2001
    Location
    Russia
    Posts
    200

    Re: VB Application


    Dim adoCommand as new ADODB.Command

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




    Andy Tower

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

Featured