Dataset save as new .mdb
-
I don't think you can do it. I've tried to before and didn't find a way to do it. There's not much to handle mdb files in c#, for instance I needed to use reflection to compact database, so maybe you can do it the same way. Anyhow there is a simpler way, you can store an empty mdb on you application as a resource and you deploy it when you need it. After that you can connect with it via OleDB andd then you can store handle it as any other database that you can connect to using OleDB. Regards.
-
Hi, First, you'd need to explain what kind of .mdb-file you want. The file-extension is used by Sql Server and Access, two different types of databases. I'd be assuming Access. First part would be getting a new db on the target-system. The easiest way to do this with Access is by adding an empty db-file as an embedded resource. Second part would be writing the data to the new database. That would be done using OleDb[^].
I are Troll :suss:
-
Hi, First, you'd need to explain what kind of .mdb-file you want. The file-extension is used by Sql Server and Access, two different types of databases. I'd be assuming Access. First part would be getting a new db on the target-system. The easiest way to do this with Access is by adding an empty db-file as an embedded resource. Second part would be writing the data to the new database. That would be done using OleDb[^].
I are Troll :suss:
-
Hi Troll Thank you for replying. I have a datset filled with a table, and i need to export this table as a new access database.
shoubi wrote:
I have a datset filled with a table, and i need to export this table as a new access database.
Start by creating an empty Access database. Then try creating an OleDb connection as suggested, and write the dataset to the database. You can always get help with specific questions here if you get stuck midway :)
I are Troll :suss:
-
shoubi wrote:
I have a datset filled with a table, and i need to export this table as a new access database.
Start by creating an empty Access database. Then try creating an OleDb connection as suggested, and write the dataset to the database. You can always get help with specific questions here if you get stuck midway :)
I are Troll :suss:
Hi Troll Thank you! i manage to do it! however i need to check for duplication of records. I have a dataset to insert into the database. How do i check for duplicate records. let say if the record has existed in the database then it will not be inserted. Thanks for reading! zheng
-
Hi Troll Thank you! i manage to do it! however i need to check for duplication of records. I have a dataset to insert into the database. How do i check for duplicate records. let say if the record has existed in the database then it will not be inserted. Thanks for reading! zheng
shoubi wrote:
Thank you! i manage to do it!
My pleasure, and good job :)
shoubi wrote:
let say if the record has existed in the database then it will not be inserted.
That's the job of the Primary Key[^]. As an example, a single person would be uniquely identified by his/her social security number, so we could make that our primary key. That would make the database guard against duplicates in that table, based on the contents of the "social security number"-field. Another way to prevent duplicates would be using the
UNIQUE
[^]-constraint.I are Troll :suss:
-
shoubi wrote:
I have a datset filled with a table, and i need to export this table as a new access database.
Start by creating an empty Access database. Then try creating an OleDb connection as suggested, and write the dataset to the database. You can always get help with specific questions here if you get stuck midway :)
I are Troll :suss:
hi troll how to transfer values from one datatable to another datatable. For example there are 2 datatables Table A and Table B. If then column name in Table A is the same as Table B then all the values of that column will go into Table B of the same column name. Hope you understand me. Thank you zheng
-
hi troll how to transfer values from one datatable to another datatable. For example there are 2 datatables Table A and Table B. If then column name in Table A is the same as Table B then all the values of that column will go into Table B of the same column name. Hope you understand me. Thank you zheng
Hi :) The easiest way to do so would be in Sql, combining a
SELECT
with anINSERT
statement. The code below should work with the AdventureWorks database;INSERT INTO Person.Contact (
FirstName,
LastName,
Title,
PasswordHash,
PasswordSalt)
SELECT FirstName,
LastName,
Title,
PasswordHash,
PasswordSalt
FROM Person.ContactHope this helps :)
I are Troll :suss:
-
Hi :) The easiest way to do so would be in Sql, combining a
SELECT
with anINSERT
statement. The code below should work with the AdventureWorks database;INSERT INTO Person.Contact (
FirstName,
LastName,
Title,
PasswordHash,
PasswordSalt)
SELECT FirstName,
LastName,
Title,
PasswordHash,
PasswordSalt
FROM Person.ContactHope this helps :)
I are Troll :suss:
-
hi troll thank you for replying:) i would like to copy values of a column in the dataset to another column in another dataset. the condition is: if the both column name is the same. thank you!
-
shoubi wrote:
the condition is: if the both column name is the same
..and do you know how to check that?
I are Troll :suss:
-
shoubi wrote:
thank you for your help... i managed to do it!
I wasn't much help, so the credit is yours - well done :)
I are Troll :suss:
hi troll i need your help again. how do i insert the dataset into the database. here is my code: string SelectSchema = "SELECT * FROM [Package Data Range]"; DataSet ds = new DataSet(); OleDbDataAdapter adapterPkInfo = new OleDbDataAdapter(SelectSchema, ImportCon); adapterPkInfo.FillSchema(ds, SchemaType.Source, "PackageDataRangeSchema"); DataSet ds2 = new DataSet(); string selectPkInfo = "SELECT * FROM [Package Data Range]"; OleDbDataAdapter adapter = new OleDbDataAdapter(selectPkInfo, connection); adapter.Fill(ds2, "Package Data Range"); ds.Tables[0].Merge(ds2.Tables[0],true,MissingSchemaAction.Ignore); i would like to insert the dataset ds into the database. thank you zheng
-
Hi, First, you'd need to explain what kind of .mdb-file you want. The file-extension is used by Sql Server and Access, two different types of databases. I'd be assuming Access. First part would be getting a new db on the target-system. The easiest way to do this with Access is by adding an empty db-file as an embedded resource. Second part would be writing the data to the new database. That would be done using OleDb[^].
I are Troll :suss:
-
hi troll I have another question, however it is not related to this. Hope you can give me your professional advice. I have a C# dll, I want to call it from a C++ program. How do I import this dll into the C++. thank you :)
shoubi wrote:
I have another question, however it is not related to this.
No problem, but you would have gotten more reactions if you created a new post.
shoubi wrote:
How do I import this dll into the C++
Using a Platform Invoke[^] would be the easy way to call unmanaged code. If you want to wrap an existing unmanaged type, then look here[^]. Enjoy :)
I are Troll :suss: