How to Add/Update/Delete Record using MS Access Database
The primary purpose of this code is to teach beginner programmer to familiarize the concept of database programming.
This is particularly for beginner but may also applicable for intermediate programmer.
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
Comments
SIR
i read ur code ...and there
hi gud pm., can i ask? how
hi gud pm., can i ask? how can i run the program that ive download already?? i need ur reply now., thank you..
re: hi gud pm., can i ask? how
Don't be too rush when asking question. You need to be polite sometimes to be answered.
You need vb.net to run this source code.
re: find record from database
That's pretty simple. Just add a textbox and modify the SQL string. If you still don't know how to do this then reply to this msg and I will create one for you if I have time.
finding a record
microsoft visual studio 2005-code for add,delete,edit and save
gud day sir!!
vb.net Version
I have been coding for several years and now using vb.net 2008. When I try to run your code I get an error on Object reference not set to an instance of an object,
newRow = dt.NewRow() Line 98 I set dt = new datatable because 99% of the time when I see this error it is because the the instance was not created as a new instance. Any Ideas? What version did you code this in ? Thanks Dwain
THANK for this code, , ,,
re: vb 2008
vb2008
vb2008(list view)
re: vb2008(list view)
Hello Joomar
re: Hello Joomar
Hello Jomar
I suggest you take a loot at
retrive image!!!
- Imports System.Data.OleDb
- Imports System.IO
- Public Class Form7
- Public ImageSlno As Integer
- Public con As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source =C:\Documents and Settings\Pankaj Arora\My Documents\database.mdb") ' connection srting
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Call Insert_Image()
- End Sub
- Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
- Try
- OpenFileDialog1.Filter = "Bmp Files(*.bmp)|*.bmp|Gif Files(*.gif)|*.gif|Jpg Files(*.jpg)|*.jpg"
- OpenFileDialog1.ShowDialog()
- PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName)
- Catch
- End Try
- End Sub
- Public Sub Insert_Image()
- Try
- Dim st As New FileStream(OpenFileDialog1.FileName, FileMode.Open, FileAccess.Read)
- Dim mbr As BinaryReader = New BinaryReader(st)
- Dim buffer(st.Length) As Byte
- mbr.Read(buffer, 0, CInt(st.Length))
- con.Open()
- Dim Str As String = "insert into imageTable(photo) values(?)"
- Dim Cmd As New System.Data.OleDb.OleDbCommand(Str, con)
- Cmd.Parameters.Add("@photo", System.Data.OleDb.OleDbType.Binary, buffer.Length).Value = buffer
- Cmd.ExecuteNonQuery()
- Catch ex As Exception
- End Try
- End Sub
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- Try
- Call LoadPhoto(ImageSlno)
- Catch ex As Exception
- End Try
- End Sub
- Public Sub LoadPhoto(ByVal slno As Decimal)
- ' display image from the database
- Try
- Dim str As String = "SELECT photo FROM ImageTable WHERE slno = " & slno
- con.Open()
- Dim cmd As New OleDb.OleDbCommand(str, con)
- Dim b() As Byte
- b = cmd.ExecuteScalar()
- If (b.Length > 0) Then
- Dim stream As New MemoryStream(b, True)
- stream.Write(b, 0, b.Length)
- DrawToScale(New Bitmap(stream))
- End If
- Catch ex As Exception
- 'MsgBox(ex.ToString)
- End Try
- End Sub
- 'Function to Create Instance For the Image From the Buffer
- Private Sub DrawToScale(ByVal bmp As Image)
- PictureBox1.Image = New Bitmap(bmp)
- End Sub
- Private Sub Form7_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- End Sub
- End Class
Use the following code.
- Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
- Try
- ImageSlno = ComboBox1.Text
- Call LoadPhoto(ImageSlno)
- Catch ex As Exception
- End Try
- End Sub
hi, How to insert a data
Kindly study Database
Upadte Database in webserver
re: Upadte Database in webserver
Manipulation of datasource of report viewer
hi bro..
for save in ms .access data base
Kindly download one of the
hello
help pls.. urgent..
re: help pls.. urgent..
ListView Groups...
how to add image in ms access 2003
re: how to add image in ms access 2003
how to create database on ms access by using vb.net code
problems in moving records
Could you please provid the
Add new comment
- Add new comment
- 2356 views