Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7628769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:39:28+00:00 2026-05-31T05:39:28+00:00

Dim staffid = TextBox1.Text Dim conn As New SqlConnection conn.ConnectionString = SqlDataSource1.ConnectionString Dim command1

  • 0
Dim staffid = TextBox1.Text
    Dim conn As New SqlConnection
    conn.ConnectionString = SqlDataSource1.ConnectionString

    Dim command1 As New SqlCommand("SELECT StaffDetails.StaffID, SUM(HolidayRequests.RequestTotalDays) AS Expr1 FROM HolidayRequests INNER JOIN StaffDetails ON HolidayRequests.Username = StaffDetails.UserName WHERE (StaffDetails.StaffID = staffID) GROUP BY StaffDetails.StaffID, HolidayRequests.ApprovalStatus HAVING (HolidayRequests.ApprovalStatus = N'approved')", conn)
    Dim command2 As New SqlCommand()
    conn.Open()
    Dim rdr As SqlDataReader
    rdr = command1.ExecuteReader
    Dim UpdateQuery As String
    While (rdr.Read())

        UpdateQuery = "UPDATE HolidayEntitlement set Holiday_Taken = @Expr1"
        command2.Parameters.AddWithValue("@Expr1", rdr("Expr1").ToString())

        'run update query

        command2.CommandText = UpdateQuery
        command2.ExecuteNonQuery()

        conn.Close()
    End While

The following error:
command2.ExecuteNonQuery: Connection property has not been initialized.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:39:30+00:00Added an answer on May 31, 2026 at 5:39 am

    Hi you need to create a second command object. Since you are reading from the same command object you are trying to execute the update statement with.

    Furthermore you are closing the connection inside the while-loop. you have to do this afterwards.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Dim conn As OleDbConnection Dim cmd As OleDbCommand Public Sub openDB() conn = New
Dim con As New OleDb.OleDbConnection Sub connecttodatabase(ByVal fileselected As String) Dim databasepassword con.ConnectionString =
Dim command_sbsp As New OleDbCommand(SELECT * FROM SNOMED_ORG_INFO WHERE ConceptID=@ID AND Genus='SALMONELLA' AND SubSpecies=@Subsp,
Dim hex = 41 Dim text As New System.Text.StringBuilder For i As Integer =
I have this code: Dim myConn As SqlConnection Dim cmd As SqlCommand Dim sqlstring,
Try Dim ds As DataSet = SqlHelper.ExecuteDataset(ConfigurationManager.ConnectionStrings(connstr).ConnectionString, CommandType.StoredProcedure, Get_All, New SqlParameter(@userid, Session(userid))) rptBundles.DataSource =
Dim xbg As Rm xbg.LobId = cmb_lob.SelectedValue xbg.Mobile = mobno.Text xbg.BusinessFax = faxno.Text xbg.BusinessPhone
Dim objMail As New Mail.MailMessage(no-reply@mywebsite.com, ToEmail, Password Reset, body) ...and the problem is that
Dim CustID As String = txtSrchCustID.Text Dim FirstName As String = txtNewCustFName.Text Dim SecondName
Dim db As New SQLDataContext Try Dim deleteBoatPics = (From boat In db.Photos Where

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.