|
Hi all,first sorry if my english in bad
I'm working on a small project for university and I'm using C#.net with sql server 2005(I'm pretty new with both of them ) .creating database and adding data was ok, BUT I've got stuck in "finding and editing" section I'm using MSDN help and walkthroughs.
I used tabaleAdapter for adding rows and for locating and editing I tried to use FindBy method and as I mentioned its not working, heres the problem:
I used [this]tutorial (I'm having the first situation!) and tried to do like whats said in there! so heres my code:
0:
1:csmDataSet.T_MemberRow membersRow1 = csmDataSet1.T_Member.FindByID(1212);
2:membersRow1.F_Name = ("john");
the first error occured in the first line saying : " csmDataSet1 does not exist " I solved this problem with adding another line before the other two (line 0):
csmDataSet csmDataSet1 = new csmDataSet();
I'm not sure if it was a right descision to use this code.
second problem(the MAIN problem!) occured in line 2 after adding this line
it says:
Title:NullRefrenceException was Unhandled
->Object reference not set to an instance of an object.
I should mention that a record with ID=1212 exist in the table but in autos window the value for membersRow1 is Null, I tried some other methods like beginEdit(),IsNull and.. the all have the Error And Ive searched the net and some forums but I couldnt find a solution although I think it should be A basic problemm!!
the membersRow1 object is already created I have no idea whats the reason for this error!
I'm in a short of timee and it's driving me nutss , I'd really appreciate it if anyone could help me with this problem, Thankyou for Your Patience thanks in advance for ur replies.
|
|
|
|
|
Is it possible to do a distributed transaction across two processes where one process calls the other using .NET remoting? (I'm using .NET 2.0)
Specifically, I have a system that manages work orders, and sometimes the work order requires an adjustment to stock. The stock system uses a .NET service that runs on a server. I'd like to start the completion process of the work order in a distributed transaction, call the stock management service, enlisting it in the transaction, and then finally complete or rollback the transaction in the original work order process. I have access to the stock management source code, so modifying or adding a new method isn't a problem.
If anyone has done this or knows if it would work, where to find an example or if there are any "tricks" that must be done, I'd appreciate any feedback or thoughts on this. I've never done any practical work with distributed transactions, just read the theory from books and simple examples.
Thanks for the help,
Trevor B
|
|
|
|
|
I have the following code:
sqlDataAdapter2.SelectCommand.Parameters["@Id"].Value = intId;
sqlDataAdapter2.SelectCommand.Parameters["@Bdate"].Value = dtpFrom.Value;
sqlDataAdapter2.SelectCommand.Parameters["@Edate"].Value = dtpTo.Value;
int intRows = sqlDataAdapter2.Fill(dataTime1,"Timesheet");
dgTime.Update();
The fill method is returning the right amount of rows (double check wwith a query)
dgTime's datasource property is dataTime1.schema.
But the datagrid never get's populated?
Any ideas? Anymore info you may need to help me?
Thanx in advance!
Jude
|
|
|
|
|
Did you bind the datagrid. Update is, if I remember, to put changes made in the data grid back into the database.
|
|
|
|
|
Desktop App, not web...No databind() for this object
Jude
|
|
|
|
|
|
OK - check this out. I just ran a simple test to comfirm something. Here is what I did step by step.
1) Create new project(Windows Application).
2) Dragged a sqlDataAdapter onto the form.
3) Went through the wizard (create new connection, use sql statements, query builder, chose table, chose all columns.
4) Generate Dataset.
5) Dragged DataGrid onto form.
6) Set the Datasource property of the datagrid to the dataset.table
7) Added sqlDataAdapter.Fill to the load method of the form.
Worked fine.
I am doing the same with the project in question. The only difference is in the SELECT Statement. I am joining two tables into the data set and it is a stored procedure.
Jude
|
|
|
|
|
Hi,
We have implemented a Windows c# application using a typed dataset (ADO.NET)
I've modified the relation so the childs get deleted when the parent is deleted. Delete action: cascade.
In the function where I process all the changes in the dataset (Dataset.GetChanges()),
I create for every table 1 adapter & call the .Update() function.
When the first adapter (for parent) is created & called the .Update() function, the parent and all its childs are deleted due to the relationship (Delete action: cascade)
A few lines further on, the adapter of the childs are called and the .Update() function throws an exception because the child is already deleted on the DB! This is very ennoying and I really don't know how to solve this problem.
Any idea how to solve this? I tested it out with my own SqlCommand object and the deletion of the parent & childs did not cause any problems.
I'd really love to keep the relationship so the childs get deleted automatically. This allows me to write less code
Best regards,
Jens
|
|
|
|
|
|
Hi,
Performing the updates in the correct order is not a good solution aswell.
I have put the table adapter update of parent at the end, but this comes with another problem.
Let's say you have to create the parent, the table adapter needs to first do the inserts of the parents, otherwise the children won't be added because of the relationship!
Any other solutions?
Best regards,
Jens
|
|
|
|
|
Perhaps I was not clear enough in my previous post. When updating a data source containing multiple related tables, you should update in this order:
1. ChildTable Deleted Records
2. New, Modified, and Deleted ParentTable Records
3. New ChildTable Records
4. Modified ChildTable Records
This order ensures that updates can be performed properly, taking into account the relationship between the tables.
The link in my previous post will walk you through how to update records based on their status (Added, Modified, Deleted).
Hope this helps.
|
|
|
|
|
i wnat to create a backup from a database in local my SQL Server(2000)
to the another computer on the network.
for this reason i define a backup device with Sp_addumpdevice stord procdure
and device create successfully but when execute the command
(Backup database GrantBooks to MyDeviceName )in the Query analyzer i give message that backup database perform successfully but the backup not exist
on the device path and backup not created.
what i do for this problem?
thanks a lot.
CuttingEdge
|
|
|
|
|
Friendz,
Is there any way where in I can delete a column(s) from DataTable programatically in .NET 2005.
Regards,
Vipul Mehta
Regards,
Vipul Mehta
Software Engineer
Chenoa Information & Software Services Pvt Ltd
|
|
|
|
|
DataTable.Columns.Remove("ColumnName") or DataTable.Columns.Remove(ColumnIndex) or
DataTable.Columns.RemoveAt(ColumnIndex)
|
|
|
|
|
Hi,
I have the following table:
Name Value
---- -----
Paul NULL
Mary NULL
Paul 0
What query can I use to detect Mary (the only one that has no values), but not Paul?
thanx
|
|
|
|
|
Hi please confirm if this is what you want
SELECT * FROM DUMMY WHERE name IN (SELECT Name FROM Dummy GROUP BY Name HAVING COUNT(Name) = 1)
Svt
|
|
|
|
|
<br />
select Name<br />
from table<br />
where value is null<br />
and name not in<br />
(select Name<br />
from table<br />
where value is not null)<br />
Mike Lasseter
|
|
|
|
|
When I type this in a command window: aspnet_regsql -S localhost -E -d MyComics –ed
I get "The argument -ed is invalid".
Any ideas why? I am running this against a sql 2005 database.
|
|
|
|
|
This option is for SQL Server 7.0 or 2000. You don't need to configure a database for a cache dependency in SQL Server 2005 - this is a native feature of the database server.
See [^] for information on getting SqlCacheDependency working on SQL Server 2005.
|
|
|
|
|
DB: SQL Server 2000
I am having trouble writing a SQL statement to pull the most current data about a record out of a table and would appreciate if someone could shed some light on the situation. Example tables below:
<br />
tbl_Item<br />
ItemID<br />
Color<br />
Type<br />
CreatedDate<br />
CreatedBy<br />
<br />
<br />
tbl_ItemValue<br />
ValueID<br />
ItemID<br />
Value<br />
UpdatedDate<br />
UpdatedBy<br />
Everytime the value changes for an item, as new record is created in the tbl_ItemValue table. I need to create a query that joins the two tables and shows the most current value for each item in the tbl_Item table. Most current value would be the record with the most current UpdatedDate that has the same ItemID in tbl_ItemValue. Therefore, my view should look something like this:
<br />
vw_Item_Value_Current<br />
ItemID<br />
Color<br />
Type<br />
CreatedDate<br />
CreatedBy<br />
Value<br />
UpdatedDate<br />
UpdatedBy
Any help would greatly be appreciated.
|
|
|
|
|
Here's one way:
select * from tbl_Item itm
inner join tbl_ItemValue val on itm.itemid = val.itemid
inner join (Select max(updateddate) as MaxDate, itemid
from tbl_itemValue
group by itemid) as val2 on val.UpdatedDate = val2.MaxDate and val.ItemID = val2.ItemID
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
Thanks for the help. That worked.
|
|
|
|
|
when i use oledb connection with following connectionstring, i can connect to SQL SERVER named DOCTOR
"Provider=SQLOLEDB.1;Persist Security Info=False;User ID=SA;Initial Catalog=LASEREPI;Data Source=DOCTOR"
but when i use SQLCLIENT.SQLCONNECTION with following string, i cant connect what is missing?:S
"Persist Security Info=False;User ID=SA;Initial Catalog=LASEREPI;Data Source=DOCTOR"
|
|
|
|
|
greekius@hotmail.com wrote: i cant connect what is missing?:
A password?
|
|
|
|
|
DON"T CROSS POST YOUR QUESTIONS
only two letters away from being an asset
|
|
|
|