I have 4tables & I write class for all those table to hold a tables information as one whole unit.
I am using MS Access queries, just like stored procedures so the queries (select, update, delete, insert) are in the access database file.
I did this for Saving Information to my database..
......
1. I opened my access db, clicked on the "queries" tab, and created a query in SQL design mode. ALL i did was type in my Query:-
(query Name = GetTable1Info)
INSERT INTO Table1( FirstName, MName, LastName, Picture)
SELECT Table1.Fst AS Expr1, Table1.Med AS Expr2, Table1.Lst AS Expr3, Table1.Pic AS Expr4;
......
second I write this in Class to control everything (VB.Net 2008):-
Imports System.Data.Ole Db
Public Class all
Private Shared conn As New OleDbConnection ("Provider = Microsoft.Jet.O LEDB.4.0; Data Source =" & _
Application.Sta rtupPath & "/mydatabase.mdb" )
Public Shared Function GetTable1() As ArrayList
Dim al As New ArrayList()
Dim c As New OleDbCommand("G etTable1Info", conn)
c.CommandType = CommandType.Sto redProcedure
conn.Open()
Dim dr As OleDbDataReader = c.ExecuteReader ()
While dr.Read
Dim T1 As New Table1(dr.Item( "ID"), _
dr.Item("FirstN ame"), _
IIf(dr.Item("MN ame").Equals(DB Null.Value), "", dr.Item("MName" )), _
dr.Item("LastNa me"), _
ByteArrayToImag e(dr.Item("Pict ure")))
al.Add(T1)
End While
dr.Close()
c.Dispose()
conn.Close()
Return al
End Function
End Class
......
so I add a new form for saving new info to my table1 like this in save button:-
Dim T1 As New Table1(0, TextBox1.Text, TextBox2.Text, TextBox3.Text, PictureBox1.Ima ge)
all.GetTable1(T 1)
......
it works.
but my problem is how can I do the same thing for delete ,update and search ..
I try but once make error in my query and once more make error in code
...
wish any one help me to made it...
I am using MS Access queries, just like stored procedures so the queries (select, update, delete, insert) are in the access database file.
I did this for Saving Information to my database..
......
1. I opened my access db, clicked on the "queries" tab, and created a query in SQL design mode. ALL i did was type in my Query:-
(query Name = GetTable1Info)
INSERT INTO Table1( FirstName, MName, LastName, Picture)
SELECT Table1.Fst AS Expr1, Table1.Med AS Expr2, Table1.Lst AS Expr3, Table1.Pic AS Expr4;
......
second I write this in Class to control everything (VB.Net 2008):-
Imports System.Data.Ole Db
Public Class all
Private Shared conn As New OleDbConnection ("Provider = Microsoft.Jet.O LEDB.4.0; Data Source =" & _
Application.Sta rtupPath & "/mydatabase.mdb" )
Public Shared Function GetTable1() As ArrayList
Dim al As New ArrayList()
Dim c As New OleDbCommand("G etTable1Info", conn)
c.CommandType = CommandType.Sto redProcedure
conn.Open()
Dim dr As OleDbDataReader = c.ExecuteReader ()
While dr.Read
Dim T1 As New Table1(dr.Item( "ID"), _
dr.Item("FirstN ame"), _
IIf(dr.Item("MN ame").Equals(DB Null.Value), "", dr.Item("MName" )), _
dr.Item("LastNa me"), _
ByteArrayToImag e(dr.Item("Pict ure")))
al.Add(T1)
End While
dr.Close()
c.Dispose()
conn.Close()
Return al
End Function
End Class
......
so I add a new form for saving new info to my table1 like this in save button:-
Dim T1 As New Table1(0, TextBox1.Text, TextBox2.Text, TextBox3.Text, PictureBox1.Ima ge)
all.GetTable1(T 1)
......
it works.
but my problem is how can I do the same thing for delete ,update and search ..
I try but once make error in my query and once more make error in code
...
wish any one help me to made it...
Comment