Click here to Skip to main content
15,895,283 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: DataContext Not Updating Its Database Pin
Sonhospa3-Sep-12 7:21
Sonhospa3-Sep-12 7:21 
QuestionToggling ON/OFF VB6 reference library in Visual Studio Pin
juno10131-Aug-12 6:27
juno10131-Aug-12 6:27 
AnswerRe: Toggling ON/OFF VB6 reference library in Visual Studio Pin
Dave Kreskowiak31-Aug-12 7:26
mveDave Kreskowiak31-Aug-12 7:26 
GeneralRe: Toggling ON/OFF VB6 reference library in Visual Studio Pin
juno10131-Aug-12 9:06
juno10131-Aug-12 9:06 
GeneralRe: Toggling ON/OFF VB6 reference library in Visual Studio Pin
Dave Kreskowiak31-Aug-12 9:26
mveDave Kreskowiak31-Aug-12 9:26 
GeneralRe: Toggling ON/OFF VB6 reference library in Visual Studio Pin
juno1011-Sep-12 17:49
juno1011-Sep-12 17:49 
GeneralRe: Toggling ON/OFF VB6 reference library in Visual Studio Pin
Dave Kreskowiak1-Sep-12 18:42
mveDave Kreskowiak1-Sep-12 18:42 
QuestionHow to insert an ID number to another table column Pin
garyu8730-Aug-12 20:56
garyu8730-Aug-12 20:56 
VB
Sub Query_Insert_Test()
    Try
        AddQuery = "Begin Transaction "
        AddQuery &= "INSERT INTO tblFoodAndBeverage(Breakfast,Lunch,Dinner,Supper,Snack,Beverage,Grocerries,Sub_Total) VALUES('" & txtBreakFeast.Text & "','" & txtLunch.Text & "','" & txtDinner.Text & "','" & txtSupper.Text & "','" & txtSnack.Text & "','" & txtBeverage.Text & "','" & txtGroceries.Text & "','" & txtSubFnB.Text & "')"
        AddQuery &= "INSERT INTO tblExpenses(Date, <big>Food_And_Beverage</big>, Allowance, Total,Wallet) VALUES('" & DateTimePicker1.Value & "',(S<big>ELECT Food_And_BeverageID FROM [tblFoodAndBeverage],[tblExpenses] WHERE tblFoodAndBeverage.Food_And_BeverageID = tblExpenses.ExpensesID and tblExpenses.Date = '" & DateTimePicker1.Value &</big> "'),'" & txtAllowance.Text & "','" & txtTotalUsage.Text & "','" & txtWalletCash.Text & "')"
        AddQuery &= "Commit Transaction "


        cmd = New SqlCommand(AddQuery, connection)
        connection.Open()

        Dim Check As Integer = cmd.ExecuteNonQuery()
        If Check > 0 Then
            MsgBox("Record Inserted.")
            connection.Close()
        Else
            MsgBox("Error. Record not inserted.")
        End If
    Catch ex As Exception
        MessageBox.Show(ex.Message & " #################### " & ex.ToString)
    End Try

End Sub


I need to insert the Food_And_BeverageID number to tblExpenses's Food_And_Beverage.
Is there any better query to select only the correct value and also a single row data.
Adding one record is okay but when I need to add another one it doesn't work and display error subquery doesn't allow to return multiple value.

Info the ID's is in Auto Number.
AnswerRe: How to insert an ID number to another table column Pin
Wayne Gaylard30-Aug-12 22:24
professionalWayne Gaylard30-Aug-12 22:24 
GeneralRe: How to insert an ID number to another table column Pin
garyu8730-Aug-12 23:09
garyu8730-Aug-12 23:09 
GeneralRe: How to insert an ID number to another table column Pin
Wayne Gaylard30-Aug-12 23:19
professionalWayne Gaylard30-Aug-12 23:19 
GeneralRe: How to insert an ID number to another table column Pin
Simon_Whale30-Aug-12 23:20
Simon_Whale30-Aug-12 23:20 
GeneralRe: How to insert an ID number to another table column Pin
garyu8731-Aug-12 0:12
garyu8731-Aug-12 0:12 
GeneralRe: How to insert an ID number to another table column Pin
Wayne Gaylard31-Aug-12 0:19
professionalWayne Gaylard31-Aug-12 0:19 
GeneralRe: How to insert an ID number to another table column Pin
garyu871-Sep-12 20:22
garyu871-Sep-12 20:22 
QuestionRemove controls from a form using For Each Pin
Steven St. John30-Aug-12 5:30
Steven St. John30-Aug-12 5:30 
AnswerRe: Remove controls from a form using For Each Pin
ChandraRam30-Aug-12 8:03
ChandraRam30-Aug-12 8:03 
GeneralRe: Remove controls from a form using For Each Pin
Steven St. John30-Aug-12 12:23
Steven St. John30-Aug-12 12:23 
AnswerRe: Remove controls from a form using For Each Pin
kureigu maikeru31-Aug-12 2:33
kureigu maikeru31-Aug-12 2:33 
GeneralRe: Remove controls from a form using For Each Pin
Steven St. John31-Aug-12 4:15
Steven St. John31-Aug-12 4:15 
GeneralRe: Remove controls from a form using For Each Pin
Simon_Whale31-Aug-12 4:43
Simon_Whale31-Aug-12 4:43 
GeneralRe: Remove controls from a form using For Each Pin
ChandraRam31-Aug-12 8:18
ChandraRam31-Aug-12 8:18 
GeneralRe: Remove controls from a form using For Each Pin
Simon_Whale31-Aug-12 9:04
Simon_Whale31-Aug-12 9:04 
GeneralRe: Remove controls from a form using For Each Pin
Steven St. John1-Sep-12 3:52
Steven St. John1-Sep-12 3:52 
QuestionWPF: delete item per Drag&Drop Pin
Christopher James Kleinheinz29-Aug-12 21:07
Christopher James Kleinheinz29-Aug-12 21:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.