Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Can I Delete All The Records Of The Access Table


Hello,

I want to delete all the records stored in access 2000 table with one function using recordset object in vb.


Thanking in anticipation.


Regards.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Delete Records From An Access Table
I'm trying to delete alot of records from an Access table via VB (350,000) records to be exact. When the code below runs, I get a error saying the record is locked, and the deletion fails. Any ideas how i can overcome this problem?

ssql1 = "select * from [purchase orders]"
rs.Open ssql1, cn, adOpenDynamic, adLockOptimistic
ssql1 = "delete from [purchase orders]"
cn.Execute (ssql1)
rs.Close

Can I Delete All The Records Of Access Table At One Time
Hello,

I want to delete all the records stored in access 2000 table with one function using recordset object in vb.


Thanking in anticipation.


Regards.

How To Delete Records In One Table Based On List In Second Table
Hi,

I have 2 tables

tbl_Docs  with Fields:  
 - ID1 (Autonumber)
 - DocRef (Integer)
 - Others (Text)

tbl_DeleteList  with fields
 - ID2 (Autonumber)
 - DocToDelete (Integer)

I want to write a query to delete those records in tbl_Docs where the DocRef matches the list in tbl_DeleteList (field DocToDelete)

I know how to do the simple delete for a single record
CODE
DELETE tbl_docs.* FROM tbl_docs WHERE (((tbl_docs.DocRef)=2))

Delete All Records From A Table?
I want to delete all the records in a table in Access. How would I do this? Would I open the recordset then delete them?

This is what I have thought of:


Code:
Dim db As DAO.Database
Dim tblApp As DAO.Recordset

Set db = CurrentDb

Set tblApp = db.OpenRecordset("Appointments")

If tblApp.EOF And tblApp.BOF Then

With tblApp
'This is where I need the code to every record in every field
End With
End If
End Sub

What code would I use?

Delete All Records In A Table
How can I handle this ?.
Today I am using sql-query against my access-database for
getting data and update data in my tables.
But how can I simply delete all records I have in a specific table ?.

I can do it simply from access, but I need code for running this from my
VB application.

Delete Table Records?
I would like to delete every record in one table I have on my program. Can I have the code to do this?

Im using a data control

Delete All The Records In A Table.
I know how to step through and delete each record but is there a faster way? Maybe wipe the entire table in a few commands or just one?

Vb6 How To Delete Fox Pro Table Records
By vb6 When I delete fox pro records, They are being selected but remain as selected records in the table
How could i completey delete them?

How To Delete Records In A Table
I'm using ADO for accessing Access DB.
I've tried to delete the records in the table using SQL command.
TRUNCATE TABLE <table name>
But it is not accepting. Is there any possibilities?

Delete Specific Records From A Table.
I need to delete specific records from a table using ADODB
code. I have tied the following
Code:
Option Explicit

Private WithEvents Cn As ADODB.Connection
Private WithEvents rsRecordSet As ADODB.Recordset

Form_Load()
Set Cn = New ADODB.Connection
Cn.CursorLocation = adUseClient
Cn.Open dataBase

Set rsRecordSet = New ADODB.Recordset
rsRecordSet.Open "Select * From QuoteDets WHERE QuoteNo = " & cboQuoteNo.Text, Cn, adOpenStatic, adLockOptimistic
End Sub

Delete()
'I want to say "Delete * From QuoteDets WHERE QuoteNo = " & cboQuoteNo.Text
'But .Execut isn't an option for rsRecordSet
End Sub

Delete Specific Records From A Table.
How do I delete specific records from a table using an SQL statement?
e.g. Delete * From QuoteDets WHERE QuoteNo = " & cboQuoteNo.Text

I am using the adodc component to link to the database.

Any Shorter Way To Delete All Records From Table?
I want to remove all the data in the table and then add new entries into it. I'm currently using the recorset and deleting everything and then add new entries but i get this error saying


key column information is insufficient or incorrect. Too many rows were affected by update.

Is there any other way to delete all the info from the table and update new entries?

Delete All Table Records Except For 1 Record.
Hi Guys,

I want to make a copy of my database and rename it which im sure I can handle.

Once i have the copy I want to delete all the records in one of my tables except for 1 of the records which is needed.

Im not sure how to do this,

If it were not for the fact I had to keep 1 record I would simply try


Code:
delete * from table

If anyone could suggest how I can do this Id be very gratefull.
Thanks again
C

Delete Specific Records From A Table.
How do I delete specific records from a table using an SQL statement?
e.g. Delete * From QuoteDets WHERE QuoteNo = " & cboQuoteNo.Text
I am using the adodc component to link to the database.

Delete Specific Records From A Table.
How do I delete specific records from a table using an SQL statement?
e.g. Delete * From QuoteDets WHERE QuoteNo = " & cboQuoteNo.Text

Delete The Records From The Table( Special Case)
can i write any code to delete the record from the mysql database . Any one can give me some suggestion on this . thanks.

i planing to do this . there is a table name LOG_FILE that store all the login record for my system . the number of record will keep increasing due to the login. can i write any code the automatically delete part of the records ? let say the records which since 1 month ago....

How To Delete Records That Have No Match In Distribution Table
Here is the situation:

I have two tables called Transaction and Distribution. I want to delete any Transaction records that do not have at least one matching record in the Distribution table. I constructed the following SQL statement that correctly finds the condition where a Transaction record has at least one Distribution record.


Code:

SELECT member.memno, member.lName, member.fName, transaction.ticket
FROM (member INNER JOIN [transaction] ON member.strID=transaction.memberId)
inner join distribution on transaction.ticket=distribution.ticketno;



My question is how can I find and delete the records in the statement table that have no matching records in the distribution table? Thanks.

Use VB To Append Records To An Linked Table From An Access Table
HELP! Sometimes this statement inserts records and sometimes it doesn't. Any ideas?

Select_Statement = "INSERT INTO OECSHFIL_SQL ( ... ) SELECT ... FROM PrepayRecs"
cnnAccess.Execute Select_Statement, TotalRecsAfter, adCmdText

Using ADO data control with Access2000 database. OECSHFIL is a linked Btrieve table and PrePayRecs is an Access 2000 table.
 

Access Delete Records &gt; 10
hi all,

i've not found how to do it in Tutor's corner nor searching the site. What i need is to delete all records from an Access table having more than 10 records.
( That's only the first 10 records should remain in the table )

Probably the code may look like this :

dbAcc.BeginTrans
dbAcc.Execute "delete from sduut where ... > 10 "
dbAcc.CommitTrans

please any idea ..?
thanks !

Use .xls As Reference To Delete Access Records
i want to delete records from an access table if one of the records matches another in .xls

im thinking about opening the .xls as i normally would, then store the values in an array and then create a doWhile loop to test the values in the array against the values in the table.

i just have no idea how to do it.

thanks/.

Delete Records From Access Database Via VB.NET
Please help,
I'm trying to create a little app to archive data out of an Access Db.  I've created a DSN that I can use MSQuery to connect to the mdb with and select/delete but when I try to connect from inside the .NET app it doesn't delete.

Here's the code I've got.  Plz excuse, I am very new to VB programming.

Private Sub sArchive()
        dt = dtpAchDate.Text
        Dim sql1 As Object
        sql1 = "delete from tblInvoice where InvDate < " & dt
        Dim td
        Dim cn1 As ADODB.Connection
        cn1 = New ADODB.Connection
        cn1.Open("DSN=LCAdata")
        cn1.Execute(sql1)
        cn1.Close()
        cn1 = Nothing
    End Sub

I'm getting dt from a "date/time picker" and the sql1 = delete from tblInvoice where InvDate < 1/1/2000 in the watch window.  It is the sql1 watch that I can copy/paste into MSQuery and run the delete fine.  

I've tried changing the Dim sql1 as Object to String, there is no difference, although I believe it should be String shouldn't it?  Once past this little bump, I have a few more questions like, how to list all the tables in an Access db and run the same query against each of them, like I mentioned, I'm trying to create an archiving app (that the creator of the Access db should have created in the first place) if I'm on the wrong path, please suggest, I am very much open to suggestions.

Thanks for any assistance anyone can provide.  If this is a repeat thread again, I apologize,  I did search and didn't find anything close enough to answer my problem.

Thanks again.

Delete Records In Access Database &gt; 3 Days
I have an online database that records visiters per hour and day as well as most popular pages. After collecting info for a couple months it's getting too huge.
How can i delete records more than 3 days old thru vb.
This is what i have tried with no success:


Code:
Option Explicit
Dim db As Connection
Dim WithEvents adoPrimaryRS As Recordset

cmdDelete_Click()
Set db = New Connection
db.CursorLocation = adUseClient
db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:Counters.mdb;"

'db.Execute " DELETE * FROM tblCounter WHERE Date < DATEADD(""d"", -3, NOW()) "
end sub

What am i doing wrong ?

Ms Access Delete Records Older Than Six Months
ok, my database connection is working fine, can delete etc.

need to mass delete tho, all records older than six months i wanna delete.

pretty simple, except it isnt happening, im thinking problem wi me query.


vb Code:
Private Sub mnuFileClear_Click()        If MsgBox("Are you sure you wish to delete old session data?" & vbCrLf & _              vbCrLf & "This will remove session data older than six months!", _              vbQuestion + vbYesNo + vbDefaultButton2) = vbNo Then Exit Sub                  Dim lRecCount As Long, sQuery As String            sQuery = "DELETE FROM Visits WHERE sDate<" & _             FormatDateTime(DateAdd("m", -6, Now), vbShortDate) & _             ";"                          Debug.Print sQuery    ConnOBData.Execute sQuery, lRecCount        Debug.Print lRecCount & " affected records!"    End Sub




Quote:




Originally Posted by DEBUG

DELETE FROM Visits WHERE sDate<09/09/2006;
0 affected records!






anyone spot the error? :S meh. i av got records wi the dates in march,april,may,june in 2005/2006 so should work? :S

ta

How To Delete Duplicate Records In Ms Access Using Sql Query
How To Delete Duplicate Records In Ms Access using sql query
Front End - Vb 6.0
Connection - ADO

 

Access 2002, Two Tables, Delete Duplicate Records
Hi,
I'm using Access 2002, and trying to create a query that will delete duplicate records...

Setup:
Table1, Table2.

Im trying to delete all rows from Table1 where the column called LUpdate is equal to the column LUdate in Table2...

i.e.

DELETE * FROM TABLE1 WHERE TABLE1.LUPDATE = TABLE2.LUPDATE

this doesn't want to work, does anyone have any ideas?
Appreciate it. Thanks.

Please Help Me Getting Records From An Access Table
I have a very minor problem, this how the code looks like:

Dim strDate as string
Dim SQLQ as string

strDate=Combo1.Text+Combo2.Text+Combo3.Text 'It gets date/month/year saved into a variable

SQLQ= "select * from MyTable where DateOrdered = " & strDate


It raises an error, Too few parameters or sometimes an error as missing operator. I want the records to be displayed in a ListView and if no records are found for that date it should raise an error...

Access Table Records
I am updating access database through visual basic application. However after i update the table, i find that all the records in database appear in random fashion and not in the order i updated them. I would prefer to see them in ther order i updated them. So, Can anybody suggest me is there anything wrong with my vb code or access database setup?
For updating records, I open dynaset with specific filter, use addnew and then update.
Thanx

Delete A Row From An Access Table From VB
I have a very simple, autonumber, table in Access that is used to
populate a VB form with the appropriate controls. On occasion we
may need to remove controls (for this particular application it will
be removing servers from a daily reboot list). How can I specify
the exact row I want deleted. I prefer to do it based on the 'servername' field for ease of use.

The code I tried is below but this ends up deleting the first record
in the set so it failed (or maybe I failed )

Thanks


VB Code:
Private Sub rmvsrv_cmd_Click()Dim cn As New ADODB.ConnectionDim STRCNNup As StringDim cnNNup As New ADODB.ConnectionDim rs As New ADODB.RecordsetSTRCNNup = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source = servers.mdb" cnNNup.Open STRCNNuprs.Open "SELECT * FROM servers", cnNNup, 3, 3rs.servername = srvnameDel_txtrs.deleters.Update    rs.ClosecnNNup.Close rbt_mgr_main.clrSSEnd Sub

How To Delete A Table In Access?
How do one delete a table in Access?
CurrentDB.OpenRecordset("myTable").Delete ?

Delete An Access Table
Using ADO to connect to an Access database.  If the table exists in the mdb, how do I delete it? Optionally, since I will be recreating the table (possibly with different data), how do I delete all records and leave the table structure intact?

Jim

Get Access Table/query Records
In a VB 6.0 application, I am trying to get the selected records from a table or query using the following method:



Code:
Public Function GetTableRecords(ap_Application As Access.Application, TableName As String, CurrentRow As Long, SelectedCount As Integer) As Object

Dim lobj_Table As Object 'Access.Form
Dim li_Return As Integer

li_Return = ap_Application.SysCmd(acSysCmdGetObjectState, acTable, TableName)

If li_Return = 0 Then
'Object is not open
Set GetTableRecords = Nothing
Exit Function
End If

'Make the table active
ap_Application.DoCmd.OpenTable TableName
Set lobj_Table = ap_Application.Screen.ActiveDatasheet

If lobj_Table Is Nothing Then
Set GetTableRecords = Nothing
Exit Function
End If

CurrentRow = lobj_Table.SelTop
SelectedCount = lobj_Table.SelHeight
If SelectedCount = 0 Then
SelectedCount = lobj_Table.RecordsetClone.RecordCount
End If

'DAO recordset for MDB, MDE, MDA
'ADO recordset for ADO, ADE
Set GetTableRecords = lobj_Table.RecordsetClone
Set lobj_Table = Nothing

End Function
This works great for MDB, MDE, and MDA files. Users can sort records, filter, and I always get the expected results.

However, this method doesn't work for ADP, ADE files. I get the original recordset as it was retrieved from the server.

So assume the user resorts the table in Access by clicking on the primary key column then selecting Records-Sort Descending (the records are now in reverse order). When I look at the recordset returned by the ActiveDatasheet, I do not get the newly sorted recordset. So when I see that the users first selection was row 1 and the selected count was 3, I get the first three records in the original table as stored on the server, which are now the last three records in the display. What I need is to get the first three records that are being displayed on the screen, the records that the user has actually selected.

Is there any object that will allow me to do this? Any clever workaround?

Get Number Of Records In Access Table With Vb6
I only want to figure out one thing >> get the number of records in a specific access table. I would like to use the ADODB method if at all possible. I can try something else if absolutely necessary.

I have searched this site and couldn't find any complete code that works.

My code returns 0 records:


Code:
Public Function MatchCheck() As Single

Dim MyConn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim SL As String
Dim TotRec As Single
Set MyConn = New ADODB.Connection

MyConn.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data _ Source=C:SAMSDATAMPI.mdb;"

MyConn.Open
MyConn.CursorLocation = adUseClient
SL = "SELECT Count (DM) as TotRec FROM EngineCurveTypeTBL"
Set rs = MyConn.Execute(SL)

MatchCheck = TotRec

End Function
Any help would be GREATLY APPRECIATED!!!!

Ray Straw

Deleting Out All The Records In Access Table
How can I flash-out all the record in an access database table using SQL or any other code........... im using Visual Basic............ and ADO?


Need Help

Deleting All Records From An Access Table
I'm working on a project for someone that requires that each month, the contents of a database are completely wiped, and then the new data copied over from an Excel sheet, but I'm struggling with the lines to wipe the data from the database.

I've already searched the forums, but my searchability skills have failed me! I am using the DAO reference and the only way I have ever added/update/deleted lines from a database have been to use the following kind of lines

--------------------
Dim dbname as database
Dim rsname as Recordset
Dim sqlString as string

Set dbname = OpenDatabase(location)
strString = "SELECT * FROM"
Set rsname = dbname.OpenRecordset
--------------------

And from there using the rsname.Edit or .Update etc..etc..

I think this will take some time to delete line by line, so is there a way of deleting the contents of the db in one line using a similar method?

Adding Records To MS Access Table
Hi,

I've created a table object in Microsoft Access with ADO. The table is empty and I want to now fill it with the results of a query. I've tried this the following 2 ways and things aren't working.

Method #1 gives me errors suggesting that my table is not updateable or that I've got SQL errors. The second method is using straight "SELECT...INTO" from SQL. This way, I'm getting errors suggesting SQL problems. Any possible remedies to this problem??

Thanks!!

Method #1

Code:
Private Sub populateTable(tabName As String)
Dim rsUpdate As ADODB.Recordset
Set rsUpdate = New ADODB.Recordset
Dim strTable As String

strTable = tabName
Set rsData = New ADODB.Recordset

'creates recordset representing empty table (created as an ADO table definition
'strTable is a String value representing the name of the empty table object to be filled

rsUpdate.Open "SELECT * FROM " & strTable, conn

'creates a recordset with the data to be added to the empty table from above
rsData.Open "SELECT dbo_Routes.DISTCODE, dbo_Routes.GEOGTYPE, Sum(dbo_Routes.HOME) AS SumOfHOME, Sum(dbo_Routes.BUS) AS SumOfBUS, Sum(dbo_Routes.APT) AS SumOfAPT, Sum(dbo_Routes.TOTAL) AS SumOfTOTAL, dbo_Routes.FSA FROM dbo_Routes where dbo_Routes.DISTCODE = 'cpc' and dbo_Routes.GEOGTYPE = '" & strGeogType & "' GROUP BY dbo_Routes.DISTCODE, dbo_Routes.GEOGTYPE, dbo_Routes.FSA", conn, adOpenKeyset, adLockOptimistic, adCmdText

'moves to first record of recordset to be populated
rsData.MoveFirst

'loops through data recordset and adds its records to the empty table (i.e. rsUpdate recordset)
While rsData.EOF = False
rsUpdate.AddNew
rsUpdate.Fields("homesum").Value = rsData!sumOfHOME
rsUpdate.Fields("aptsum").Value = rsData!sumOfAPT
rsUpdate.Fields("bussum").Value = rsData!sumOfBUS
rsUpdate.Fields("totalsum").Value = rsData!sumOfTOTAL
rsUpdate.Fields("fsa").Value = rsData!FSA
rsUpdate.Update
rsData.MoveNext
Wend



Method # 2


Code:
Private Sub add(tabName As String)
Dim sSql As String

sSql = "Insert Into " & tabName & "(homesum, aptsum, bussum, totalsum, fsa) " & _
"Select Sum(dbo_Routes.HOME)" & _
" , Sum(dbo_Routes.BUS)" & _
" , Sum(dbo_Routes.APT)" & _
" , Sum(dbo_Routes.TOTAL)" & _
" , dbRoutes.FSA " & _
"From dbo_Routes " & _
"Where dbo_Routes.DISTCODE = 'cpc' " & _
" And dbo_Routes.GEOTYPE = '" & strGeogType & "'" & _
"Group By dbo_Routes.DISTCODE, dbo_Routes.GEOGTYPE, dbo_Routes.FSA"

conn.Execute (sql)

End Sub

UPDATE RECORDS OF MS ACCESS TABLE
UPDATE RECORDS OF MS ACCESS TABLE ...?

Deleting All Of The Records Within A Table In Access
Is there a way for me to delete all of the records in a table in Access? The reason is, is that because I am writing a program that suppose to import data from Excel into an Access table. The data might change so I need to clear the records in order to have "fresh" data.
I was also wondering if there was some code someone could provide that checks to see if a table is already present, if not, then it creates one.

Any help would be greatly appreciated.

Help! How Do You Find Out How Many Records A Access DB Table Has?
I need some help on finding out, how to find out the number of records a specific Table in an Access Database has

Delete Table In Access If It Exists
I'm writing a program to open an Access database and delete al of the "error tables", but my problem is that I'm using the following code:


Code:
Dim appAccess As New Access.Application
Const dbPath As String = "F:Shared Files"
appAccess.OpenCurrentDatabase dbPath & "RMA.mdb"
appAccess.Visible = False
DoCmd.DeleteObject acTable, "customfields_ImportErrors"
DoCmd.DeleteObject acTable, "customfields_ImportErrors1"
DoCmd.DeleteObject acTable, "customfields_ImportErrors2"
DoCmd.DeleteObject acTable, "customfields_ImportErrors3"
DoCmd.DeleteObject acTable, "customfields_ImportErrors4"
DoCmd.DeleteObject acTable, "customfields_ImportErrors5"
DoCmd.DeleteObject acTable, "customfields_ImportErrors6"
DoCmd.DeleteObject acTable, "customfields_ImportErrors7"
DoCmd.DeleteObject acTable, "customfields_ImportErrors8"
DoCmd.DeleteObject acTable, "customfields_ImportErrors9"
DoCmd.DeleteObject acTable, "customfields_ImportErrors10"
DoCmd.DeleteObject acTable, "orders_ImportErrors"
DoCmd.DeleteObject acTable, "orders_ImportErrors1"
DoCmd.DeleteObject acTable, "orders_ImportErrors2"
DoCmd.DeleteObject acTable, "orders_ImportErrors3"
DoCmd.DeleteObject acTable, "orders_ImportErrors4"
DoCmd.DeleteObject acTable, "orders_ImportErrors5"
DoCmd.DeleteObject acTable, "orders_ImportErrors6"
DoCmd.DeleteObject acTable, "orders_ImportErrors7"
DoCmd.DeleteObject acTable, "orders_ImportErrors8"
DoCmd.DeleteObject acTable, "orders_ImportErrors9"
DoCmd.DeleteObject acTable, "orders_ImportErrors10"
'Close Access
Status.SimpleText = "Closing Microsoft Access"
appAccess.Quit acQuitSaveAll
And say if the table "orders_ImportErrors5" doesn't exist, VB will kick out and tell me it doesn't exist and will fail to close Access. Is there a way I can check to see if the table exists first before trying to delete it? Thanks!

How To Delete Parent Table Alone In Ms Access
Hai everyone, i am using ms access 2003 and vb 6. I am using three tables Table1:
Stud_id,name,dob
Table2:
Stud_id,VMAKE,VACT,VSPARK
Table3:
Stud_id,Centre_id,centrename

Table1 is the parent table with Stud_id as the primary key. I want to delete Table1 alone without deleting Table2 or Table3, but its not allowing.

How can i solve this problem.

Thank you.

Delete Data From Access Table
Anyone know of a VB 5.0 statement to clear out or delete all of the data in an Access database? I don't want to delete the table itself just clear out all of the data. Something like "TableName.clear"

Thanks,
met12

Delete Access Table By Date
Hi all Have got a VB6 app that connects to an Access 97 database. Im using a data control data1 and storing 4 fields. One of these fields is the date. With me so far ? These 4 fields build up and are not required after they become 1 day old so i want to delete them If i run the Delete From tblA it quite happly deletes the contents of the whole table. Does anyone know what i need to put in the WHERE to just delete records that are more than 1 day old ?
VB Code:
Dim db As Database db.Execute "DELETE FROM tblA WHERE FieldDate"

How To Delete Record In Access Table ?
when i try to delete the record from an access table (access 97) by vb6


strSQL = "DELETE * from TblItem"
dbconnection.Execute strSQL, lngRecsAffected


error is prompted "cannot delete from specified tables"

why ?

How To Delete Table In Access Database
You want the SQL "DROP TABLE" command

eg:

Code:
On Error Resume Next
db.Execute "CREATE TABLE tblTemp(f1 TEXT,f2 TEXT)"

If Err.Number = 3010 Then 'temp table exists
db.Database.Execute "DROP TABLE tblTemp" 'delete the temp table
db.Execute "CREATE TABLE tblTemp(f1 TEXT,f2 TEXT)"
End If

On Error GoTo ErrHandler 'reset error handler

Cannot Delete Record From Access Table
I can't seem to delete a single record from a single table in an Access Database. I keep getting an error message "Could not delete from specified tables."
My program works and it does delete when I use it as an administator, but when I run it as someone else it gives that error.

I know there are permission problems that may cause this message, so i gave the users that need the program full rights to the folder that has the database and full rights to the database itself. The database is on our web server while my program is on our file server, but like I said, the users have rights to access the database.

I have made plenty of programs before that have allowed regular users to delete from a database, but i cannot figure out why this one is giving me so many problems.

Thanks

How To Delete Access Table Programmatically ?
Hi,
I generate a backup table with the name 'backup' in an Access database in a programme. While exiting the programme I would like to delete the table inside the database. The Kill method does not work.

Is it possible to delete the tables in side the database (MDB file) ?

BVPR

Cant Delete Row From Table (access Database)
This code is supposed to delete a row in my access-database. But its just giving me a "update requires a valid deletecommand when passed datarow collection with deleted rows "-message.
I find this a bit strange, since the commandbuilder has been working when I want to update and insert rows.

Code:
    Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click

        Dim strConnect, SQL As String
        strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User Id=admin;Data Source=Datadb.mdb"
        Dim strSelect As String = "SELECT * FROM data Where ID1=" & findId.Id 'findid being a global module
        Dim Connect As New OleDbConnection(strConnect)
        Dim MyDataSet As New DataSet
        Dim myCB As OleDb.OleDbCommandBuilder()

        Try
            Connect.Open()
        Catch
            MessageBox.Show("Databas ej tillgänglig.")
        End Try

        If Connect.State.Open = 1 Then
            Try
                Dim Adapter As New OleDbDataAdapter(strSelect, Connect)
                'Load a data set.
                Adapter.Fill(MyDataSet, "data")
                'MessageBox.Show(Adapter.DeleteCommand().ToString)
                Dim Table As DataTable = MyDataSet.Tables("data")
                rows = Table.Select()
                
                Table.Rows.Remove(rows(0))
                Adapter.Update(rows)
                Adapter.Update(MyDataSet, "data")

                Table.Clear()
                Adapter.Dispose()
                Connect.Close()
            Catch ex As Exception
                MessageBox.Show("Fel: " & ex.Message)
            End Try
        End If
        lstItems.Items.Clear()
        loadDB() 'reloads the items in the listbox named lsitems
    End Sub


Anyone who has any good tips? Im using a modem dial up-connection where I am right now, so I cant google to much because many resulatlinks goes to pages that are to slow for my connection.

Delete A Table From An Access Database
Hi!

How do I programmatically delete a table from an MS Access database?

Thanks!

Delete Table In Access Database
How can I delete table in Access Database?

I try with this:

Dim dbsNew As Database
Dim wrkDefault As Workspace
Dim td As TableDef
Set dbsNew = OpenConnection("c:WindowsTempMarteleurVirtuel.mdb")

Set wrkDefault = DBEngine.Workspaces(0)
td.Name = "Position ha"
dbsNew.TableDefs.Delete td

But it was not a success. I recive an error at the last line: ("Type mismatch")


Has anyone can help me?
Thanks!

Redg

Copyright © 2005-08 www.BigResource.com, All rights reserved