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

  • Home
  • SEARCH
  • 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 7005613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:22:23+00:00 2026-05-27T21:22:23+00:00

I am using MS Access Database. Now I have to update a particular cell

  • 0

I am using MS Access Database. Now I have to update a particular cell value. Here is my code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim str As String
Dim Presc As New System.Text.StringBuilder
Dim prs As String(), j As Integer
prs = Split(txtPrescription.Text, vbCrLf)
For j = 0 To prs.Length - 1
    Presc.Append(prs(j))
    Presc.Append(",")
Next
Try
    str = Trim(lsvCase.SelectedItems(0).Text)
    'MessageBox.Show(str)
    Dim con As System.Data.OleDb.OleDbConnection
    Dim ds As New DataSet
    Dim rea As System.Data.OleDb.OleDbDataReader
    con = New OleDb.OleDbConnection
    Dim da As New System.Data.OleDb.OleDbDataAdapter
    con.ConnectionString = "Provider = Microsoft.ACE.OLEDB.12.0; Data Source= F:\Sowmya Laptop Backups\sowdb1.accdb;"
    con.Open()
    Dim cmd As OleDb.OleDbCommand = con.CreateCommand
    cmd.CommandText = "UPDATE Casehistory set Prescription =' " & Presc.ToString() & "'"
    rea = cmd.ExecuteReader
    cmd.ExecuteNonQuery()
    da.FillSchema(ds, SchemaType.Mapped)
    da.Update(ds, "Casehistory")
    con.Close()
Catch ex As Exception
Finally
End Try
End Sub

This code updates all the cells in that column. I want to update only the particular cell having Case_ID = str
Where I have to add the WHERE clause (WHERE Case_ID = ” & str & “

  • 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-27T21:22:24+00:00Added an answer on May 27, 2026 at 9:22 pm

    I would use command parameters, neater and prevents the SQL injection issue. Something like:

    cmd.CommandText = "UPDATE Casehistory set Prescription =@Presc WHERE Case_ID = @CaseID"
    cmd.Parameters.AddWithValue("@Presc", Presc.ToString())
    cmd.Parameters.AddWithValue("@CaseID",str)
    

    As an aside, having all this code in the button click event is less than ideal. You might want to investigate structuring your app in a more maintainable way – perhaps with a Data Layer for example.

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

Sidebar

Related Questions

USING MS ACCESS 2003 How to check is null value in the access database?
I have the following problem in a Database using Access 2007 as front end
I have a DataGridView that displays data from a MS Access database. I'm using
Using Access Database Table ID Time 001 100000 001 100005 001 103000 001 102500
Using Access 2003 Database Table1 Intime Outtime WorkTime OverTime 08:00:00 19:00:00 09:00:00 02:00:00 09:00:00
I am using Microsoft Access database for storing data. In that, I stored date
I'm currently developing a PHP application that's using an Access database as a backend.
Our app (already deployed) is using an Access/Jet database. The upcoming version of our
It is very simple to do paging on access database (using absolute and pagesize)
I've been writing a multi-threaded DLL for database access using ADO/ODBC for use with

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.