Filling a .mdb-File with Data through VB.net - database

i'm using oledb and DataSets on VB.net for filling an access database (.mdb).
It works in the following process:
i have an existing .mdb-file with Data in it
creating an oledb-dataadapter to the existing .mdb-file
filling a DataSet/DataTAble with the Data from the file (adapter.fill())
adding a new row to the dataset
filling the row with data
updating the dataset/datatable through the dataadapter to the .mdb file
This works so long, the problem is: I'm doing this process a few thousand times, with a few thousand datasets. From time to time, this is during longer and longer. I think it's because the dataadapter has to go through the whole database all the time and because i'm taking the whole dataset from the database all the time out, and updating it back to the database.
So my question:
is there an oppurtunity to do this in an other way? Without taking the whole data out from the database and taking it back? And without going through the whole Databse? Maybe with a sql-connection and then just adding a row to the end of the database??
Thanks for your help!

If You only adding rows - why not use SqlOleDBCommand? He has method .ExecuteScalar()

Related

Qt qsqlite db file update / remove

In my program I use qsqlite database. I changed the data in the database and then I iterated through the updated database but It took no effect, I could see only the old data. Nothing helped me until I manually deleted the db file so the new one was created, containing the desired new data.
I didn't use any exec to put my new data in the database. I just rewrote it manually with new values.
I wonder what I have to do in order to see my new data without manually deleting the db file. Can I update the binary db file? Or could I remove it after the connection is closed from within the program?
I consider this as a basic question still I can't find the answer.

DataSet Performance

Could someone explain to me why there such a difference when it comes to filling and updating DataSet?
Currently I am working on program that takes data from one db and puts them into second db. Original DB contains quite a lot of data. I wonder why it is so fast for program to fill DataSet with data, but so long to update.
Code schema looks like that:
Create Connections;
OpenConnections();
Create DataAdapter1, DataAdapter2;
Create CommandBuilder1, CommandBuilder2;
Create DataSet;
DataAdapter1.Fill(DataSet, Connection1);
DataAdapter2.Update(DataSet, Connection2);
CloseConnections();

Manual Entered Data On Excel Ms Query Is Misaligned After Refresh

I have done an MS SQL Query in excel.
I have added extra colums in the excel sheet which I want to enter manual
data in.
When I refresh the data, these manually inputted columns become misaligned
to the imported data they refer to.
Is there any around this happening.
I have tried to link the imported data sheet to a manual data sheet via
vlookup but this isn't working as there are no unique fields to link together.
Please help!
Thanks
Excel version is 2010.
MS SQL version is 2005.
There is no unique data.
Because excel firstly looks like this.
when we entered a new order in to database Excel looks like this
Try this: in the External Data Range Properties, select "Insert entire rows for new data".
Not sure, but worth a try. And keep us updated of the result !
edit: And make sure you provide a consistent sort order.
There is no relationship to the spreadsheets external data and the columns you are entering. When refreshing typically the data is cleared and updated though there are other options in the external data refresh menu you could play with. You could play around with the External data options in the menu to see if changing the settings on what happens with the new data would help.
If you want your manually entered data to link to the data in the embedded dataset, you have to establish the lookup with a vlookup or some formula to find the rows info and show it.
Basically you are thinking the SQL data on the spreadsheet is static, but it isn't unless you never refresh it or disconnect it from the database
note that Marcel Beug has given a full solution to this problem in a more recent post in this forum # Inserting text manually in a custom column and should be visible on refresh of the report
he has even taken the time to record an example in a video # https://www.youtube.com/watch?v=duNYHfvP_8U&feature=youtu.be

Populate SQL database from textfile on a background thread constantly

Currently, I would like provide this as an option to the user when storing data to the database.
Save the data to a file and use a background thread to read data from the textfile to SQL server.
Flow of my program:
- A stream of data coming from a server constantly (100 per second).
- want to store the data in a textfile and use background thread to copy data from the textfile back to the SQL database constantly as another user option.
Has this been done before?
Cheers.
Your question is indeed a bit confusing.
I'm guessing you mean that:
100 rows per second come from a certain source or server (eg. log entries)
One option for the user is textfile caching: the rows are stored in a textfile and periodically an incremental copy of the contents of the textfile into (an) SQL Server table(s) is performed.
Another option for the user is direct insert: the data is stored directly in the database as it comes in, with no textfile in between.
Am I right?
If yes, then you should do something in the lines of:
Create a trigger on an INSERT action to the table
In that trigger, check which user is inserting. If the user has textfile caching disabled, then the insert can go on. Otherwise, the data is redirected to a textfile (or a caching table)
Create a stored procedure that checks the caching table or text file for new data, copies the new data into the real table, and deletes the cached data.
Create an SQL Server Agent job that runs above stored procedure every minute, hour, day...
Since the interface from T-SQL to textfiles is not very flexible, I would recommend using a caching table instead. Why a textfile?
And for that matter, why cache the data before inserting it into the table? Perhaps we can suggest a better solution, if you explain the context of your question.

VB6/Microsoft Access/DAO to VB.NET/SQL Server... Got Advice?

I can make a DAO recordset in VB6/Access do anything - add data, clean data, move data, get data dressed in the morning and take it to school. But I don't even know where to start in .NET.
I'm not having any problems retrieving data from the database, but what do real people do when they need to edit data and put it back?
What's the easiest and most direct way to edit, update and append data into related tables in .NET and SQL Server?
The DataSet class is the place to start. As the linked article says, the steps for creating a DataSet, modifying it, then updating the database are typically:
Build and fill each DataTable in a DataSet with data from a data source using a DataAdapter.
Change the data in individual DataTable objects by adding, updating, or deleting DataRow objects.
Invoke the GetChanges method to create a second DataSet that features only the changes to the data.
Call the Update method of the DataAdapter, passing the second DataSet as an argument.
Invoke the Merge method to merge the changes from the second DataSet into the first.
Invoke the AcceptChanges on the DataSet. Alternatively, invoke RejectChanges to cancel the changes.
A natural progression IMO from DAO is ADO.net. I think you would find it pretty easy to pick up having the understanding/foundation of DAO. It uses DataAdapters and DataSets similar to recordsets. Modifying Data in ADO.NET.
I would suggest looking into Linq when you get a chance.
Is there a reason why ms-access was added as a tag here? It seems to me that the question has nothing but the most trivial relevance to Access, since once you're working with .NET, Access is completely out of the picture.
try to use oledbConnection , oledbCommand and oledbDataReader
from System.data.oledb
if you are using sqlserver DB, then use SqlConnection , sqlCommand and sqlDataReader
from System.data.SqlClient

Resources