|
Hi,
I have a question. I'm inserting a row into a table in Access DB (without using the command builder), one of the coloumns (the primary key, actually) in the table is an AutoNumber - which gets updated when I insert.
Does anyone know how can I get the coloumn's value?
thanks!
|
|
|
|
|
SELECT @@IDENTITY works for Access 2000 and later.
Edbert P.
Sydney, Australia.
|
|
|
|
|
Thank you so much! on both answers!
|
|
|
|
|
Hi ..
please see the code below..
I have two tables Centrals and Devices both having Central_Id as a common field..I am able to display the Centals table value in the first datagrid (dataGirdCentral).However on click of each cell on the central_id i want the corresponding entries of Devices table to be shown in the 2nd datagrid dataGridDevices..how do i do that...
private void loadCentralDevices()
{
ds = new DataSet();
//Getting schema of Centrals table
DataTable centralDt = new DataTable("Centrals");
String query = "Select * from Centrals";
OleDbDataAdapter da = new OleDbDataAdapter(query,ConfigurationSettings.AppSettings["MsAccess_ConnectString"]);
da.FillSchema(centralDt, SchemaType.Source);
ds.Tables.Add(centralDt);
//Getting schema of Devices table
DataTable deviceDt = new DataTable("Devices");
String query1 = "Select * from Devices";
da = new OleDbDataAdapter(query1,ConfigurationSettings.AppSettings["MsAccess_ConnectString"]);
da.FillSchema(deviceDt,SchemaType.Source);
ds.Tables.Add(deviceDt);
DataRelation dr = new DataRelation("Central_Devices_Relation",
centralDt.Columns["Central_ID"], deviceDt.Columns["Central_Id"]);
ds.Relations.Add(dr);
//create a dataview of the data
DataView centralVw = new DataView(ds.Tables["centralDt"]);
//giving access to Centrals table
centralVw.AllowDelete=true;
centralVw.AllowEdit = true;
centralVw.AllowNew = true;
//set the grid source to the author view
dataGridCentral.DataSource = centralVw;
//hook up the event handler
dataGridCentral.CurrentCellChanged+= new EventHandler(this.dataGridCentral_CellChanging);
}
private void dataGridCentral_CellChanging(object sender, EventArgs eArgs)
{
????? what do i write here to get the corresponding values?
}
Breath dot net
|
|
|
|
|
Hi All,
I have an issue with inserting new rows into a typed dataset. The dataset has two datatables (e.g. Order, OrderDetails). Both tables have a primary key (not nullable) and there is a foreign key constraint (and relation) between the OrderDetails and Order datatable.
The problem comes when trying to insert a new row into the Order (parent) table. Because I haven't been to the DB to get the next sequence number (i'm using Oracle), there is no value on the primary key. Obviously I can't add this row to the datatable unless i turn constraints off which I don't want to do. I also don't want to have to go to the database everytime I add a new row to the datatable as it could result in a stack of roundtrips to the database (each orderdetail insert would require another round trip)
Surely there is another way that I'm not aware of? What would be good is that for any new rows that are created, I put a GUID or something in the PK which would allow me to insert and relate child rows etc.. but I don't know if this is even possible or if it's best practice.
Thanks in advance for any help!
|
|
|
|
|
I updated the parent table for my application before using the PK as FK for the child table, but you might want to try this:
There is a property called DataRow.SetParentRow that sets the parent row for the child table.
I always specify this property before I update the child table, e.g.
<code>parentRow.Key = KeyValue
parentRow.Field1 = Value1
parentRow.Field2 = Value2</code>
<code>childRow.Key = parentRow.Key
childRow.Field1 = Value1
childRow.Field2 = Value2
childRow.SetParentRow(parentRow)</code>
This might help you link the two tables along with Key Fields and Foreign Key Fields setting in the dataset.
Remember that you need to update the parent table before the child table for insertion.
I hope it helps.
Edbert P.
Sydney, Australia.
|
|
|
|
|
Hi, I am debugging a COM Dll that uses ADO thru smart pointers (#import) and when recordsets are used, they were being Released with Release (); I have used recordsets in the past thru smart pointers and always used to call Close (); and then assign NULL to the recordset pointer,
so what I did with the "recordset->Release ();" lines was to change them to: "recordset = NULL;", but I wonder if I should explicitly Close them?
does anybody know how this should be? thanks a lot,
Nemike
Nemike
|
|
|
|
|
i have add reporting services to my production machine and the home page does not display its toolbar so i can not manage my reports? why do i not have a toolbar in my reporserver?
|
|
|
|
|
How to add/change/read GUID data type field on SQL server with ADO (C++)
|
|
|
|
|
use ado or ado.net to complete a etl tool, is it feasible?
I use visual C++.net, everybody, what do you think which develop tool is better? ado or ado.net?
give me some advice! thank you!
|
|
|
|
|
Hello,
Interestingly enough, I am working on an ETL tool using ADO.NET and SQL Server at the moment.
So far so good though the system is still in its infancy. And I'm learning as I go so keep in mind there may be better ways to do things other than I have done it.
Our system is focused on batch processing and so far I've run into the following with ADO.NET
1. Using DataSet for batch processing may not be viable on large tables because it uses up a lot of memory.
2. Using DataReader for batch processing large tables is great but you are not able to update the records in batch once you are done.
3. You could perform updates while you are traversing the datareader, but this results in a lot of network traffic while processing.
I'm currently trying to figure out a good way to batch the updates so that I can send them back to the database in chunks but havent figured out how I'm going to do that yet.
Hope this helps. I haven't tried using ADO through interop so I can't comment on effeciency comparison between the two.
|
|
|
|
|
Hi:
I have a small issue with Oracle Ref Cursor in dealing with a generic DAL (Data Access Component) component.
I am currently developing a generic Data Access Component targetting SQLServer, Oracle and DB2.
Only for Oracle Stored Procedures dealing with REF CURSORs, I am not able to make a mapping to a corresponding .NET DataType. The DAL can deal only with .NET datatype.
Please suggest me some workarounds to deal with this issue.
The provider is ODP.NET and Oracle 9.1 server. .NeT Framework version is 1.1
Deepak Kumar Vasudevan
Personal Web: http://www24.brinkster.com/lavanyadeepak/default.asp
I Blog At: http://deepak.blogdrive.com/
|
|
|
|
|
Hello, I have an access db that uses a recursive structure to store data i.e. there is a parts table (but there are three levels in the structure feature bill, level1 package, and then parts but they are all considered a part in the database I am extracting the nesting ability from an attribute in the parts table called style. Depending on the value of style i.e. style = 0 its a part, style = 1 it is level1package and style = 2 it is a feature bill) I am trying to generate a report that will show me for every feature bill, what level1 packages are in it and what parts are in each one of those packages. So I am essentially showing all the hierarchical levels of nesting. I am attempting to do this buy using a dataset that has multiple instances of my packages table(packages table is essentially the child element of the parts table) and linking the child node to the parent node each time until I reach the maximum amount of nesting I want. Can anyone help me out with setting up the dataset correctly? I am running into the following error:
:System.Data.ConstraintException: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
at System.Data.DataSet.FailedEnableConstraints()
at System.Data.DataSet.EnableConstraints()
at System.Data.DataSet.set_EnforceConstraints(Boolean value)
at System.Data.DataTable.EndLoadData()
at System.Data.Common.DbDataAdapter.FillFromReader(Object data, String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
at System.Data.Common.DbDataAdapter.Fill(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
I am not sure how to fix the problem and any help would be greatly appreciated, thanks in advance!
Frank
|
|
|
|
|
Hi all,
Is it possible to get a return value from an Insert Query.
Like
Dim oCmd as OleDBCommand
Dim oConn As OleDBCommand
Dim sCommand as string
sCommand = "INSERT INTO MyTable (ID, MID, Person VALUES (1256, 'Joe Doe')
'Return the New ID number ?
oCmd = New OleDbCommand(sCommand, oConn)
oCmd.ExecuteNonQuery()
The table has a autonumber Column "ID".
When I Add a new row I want now the new ID number
Thanks,
|
|
|
|
|
after your code:
oCmd = new OleDbCommand("SELECT @@IDENTITY", oConn);
int nId = (int)oCmd.ExecuteScalar();
Microsoft .NET - Come on! I need the Traffic!
|
|
|
|
|
Hi,
Could any one share with me the source in C# for adding, updating and deleting data in a SQL server database using ADO.NET.
A simple windows application would be of great help.
Thanks
Saleem.
|
|
|
|
|
You'll probably get replies that answer the request, but I'd like to put in my two cents. Instead of coding the Select, Insert, Update, Delete statements inside your app, as the responses you'll get will (according to your request) show, I'd suggest that you call stored procedures with parameters.
This will allow you to separate your SQL from your application, and provide protection from SQL injection attempts.
Microsoft .NET - Come on! I need the Traffic!
|
|
|
|
|
I have a function into which is passed a DataTable. In this function I want to export this DataTable to an MS Access database but can't seem to figure out how to do this whilst making it as generic as possible.
Anyone got any ideas, suggestions on how to do this?
SuzyB
If I had a better memory I would remember more.
|
|
|
|
|
Well, if you want to put some burdon on whoever is using this, just create a CSV and force them to import it into Access.
If you'd rather automate it, I'd suggest you name the access table
System.Data.DataTable.TableName
Start off my creating a reference to the Microsoft Access 11.0 COM Object, then use the
Microsoft.Office.Interop.Access
namespace to create your databae and tables.
Microsoft .NET - Come on! I need the Traffic!
|
|
|
|
|
Hi Suzy. Another alternative to create an MS Access table would be to use the ADOX library through COM interop. Here is a comprehensive article[^] on CodeProject that describes this, with a specific example of creating an Access database.
|
|
|
|
|
HI~
I would like to ask
Do ADO.Net not support in pocket pc platform?
what are the data type can be supported in ".cdb" database?
Is there any alternative database can be used in pocket pc (beside CEDE and SQL server)?
|
|
|
|
|
I am using XML on PPC. Check out this snippet from Inventory sample program:
Private Sub loadXMLData()<br />
<br />
Try<br />
<br />
prog.Value = 1<br />
sbStatus.Text = "Loading XML data..."<br />
<br />
prog.Value = 2<br />
Dim fs As New FileStream(txtXMLFileName.Text, FileMode.Open)<br />
<br />
prog.Value = 3<br />
Dim xr As New XmlTextReader(fs)<br />
<br />
prog.Value = 4<br />
data.ReadXml(xr)<br />
<br />
prog.Value = 8<br />
sbStatus.Text = "Loaded XML data"<br />
xr.Close()<br />
fs.Close()<br />
<br />
Catch e As System.IO.FileNotFoundException<br />
<br />
prog.Value = 8<br />
MessageBox.Show("The file '" + txtXMLFileName.Text + "' could not be found. Please select a different file name.")<br />
<br />
Catch e As XmlException<br />
<br />
prog.Value = 8<br />
sbStatus.Text = "Exception occured: " + e.ToString()<br />
<br />
End Try<br />
<br />
End Sub<br />
where data is a DataSet.
"For all of our languages, we cannot communicate" - Christy Moore, Natives
|
|
|
|
|
Hi everybody,
there is a way to hide the system-tables, views and stored procedures in the Enterprise Management Console. I know this because I've done it before. But, believe it or not, I forgot how . Can somebody tell me? (SQL 2000)
Thanks in advance,
Matthias
If eell I ,nust draw to your atenttion to het fakt that I can splel perfrectly well - i;ts my typeying that sukcs.
(Lounge/David Wulff)
www.emvoid.de
|
|
|
|
|
Figured it out. For all those that are interested: You have to untick a checkbox in the Registration-Properties.
Anyway thanks for reading.
Matthias
If eell I ,nust draw to your atenttion to het fakt that I can splel perfrectly well - i;ts my typeying that sukcs.
(Lounge/David Wulff)
www.emvoid.de
|
|
|
|
|
To all masters:
my database is db2 & oracle.
could OdbcCommandBuilder create InsertCommand, UpdateCommand and DeleteCommand against db2 or oracle tables?
(SQL Server is ok.)
i always get an exception about that there is no key infomation after i execute adapter.Update(table).
Could anyone give me a help?
Thank u very much!
paul.
|
|
|
|