|
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
|
|
|
|
|
Hi,
I think this will help to u
Cstring="Server=<systemname>;DataBase=DOCTOR;UID=sa;PWD="
Pandian S
|
|
|
|
|
greekius@hotmail.com wrote: ;User ID=SA;
Your connecting to a database using SA?
That is VERY unsecure! Highly unrecommended.
Connection strings http://www.connectionstrings.com/[^]
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
hello every one,
well I'm working on making a master detail form here. I've binded the data correctly and now I want to add the update, del, and insert new record functionality to the detail form. I'm using .net 2.0 C# and I'm working in windows Forms. I've used DataGridView class to display the detail data information.
For saving the record, I wanted to cast the datasource of DataGridView into a datatable first and then use it to iterate thru the data but it returns a null so I get the nullreferenceException. Plz tell me how to iterate thru the detail table here.
I actually deleted a few columns from the detail table ;like the PK columns and Foreign Key columns coz the user doesnt need to see those. But I do wanna have access to those esp when updatin the record. So what can I do.
if its possible plz give me a sample code or application if u can.
thanks in advance...
Rocky
|
|
|
|
|
Hi all,
just got to find an easier way, can any tell me if you can update the entire database with a new time in the timestamp field. i've got this project but the data is 14month old, it would be good if the data could be 3 or 4 days old just to debug or test a few things.
Anyway, ive been using this:-
select dateadd(d,430,timestamp)from alarm_log
this brings back the original table plus 430 days. So how do i update this data back into the table, cause i have nothing in the table to generate a whereclause.
secondly, once ive got one table updated... i could use sysobjects to find all the tables in the database and then loop through them...but how! - im sure i read somewhere that sql doesn't store a row number, there is no such thing, but surely there must be a way to interate through a table list?
Cheers Andy
|
|
|
|
|
1. If you are updating ever row in the table you don't need a where clause
<br />
update alarm_log set timestamp = dateadd(d,430,timestamp) <br />
2. Use a cursor. See Google or help in Query Analyzer for more info.
Mike Lasseter
|
|
|
|
|
It is a strange practice to name your field timestamp and then fill them with a datetime or smalldatetime data type. I'm assuming that your timestamp field is in fact a datetime or smalldatetime, because the timestamp data type is binary - and would not update without error using the dateadd as you show. Plus, the timestamp data type is updated automaticaly when you change the value of a field.
Anyway, if your timestamp fields are in fact dates, this should work:
DECLARE @cSQL varchar(100)
DECLARE @cTableName varchar(100)
SELECT @cSQL = ''
DECLARE TableNames CURSOR FOR
SELECT DISTINCT table_name
FROM INFORMATION_SCHEMA.COLUMNS
WHERE column_name = 'timestamp'
OPEN TableNames
FETCH NEXT FROM TableNames INTO @cTableName
WHILE @@FETCH_STATUS = 0
BEGIN
EXEC('UPDATE ' + @cTableName + ' SET timestamp = DATEADD(d,430,timestamp)')
FETCH NEXT FROM TableNames INTO @cTableName
END
CLOSE TableNames
DEALLOCATE TableNames
--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
|
|
|
|
|
Hi All
Very new to SQL and ASP.Net but need to populate a lable from a SQL query.
<br />
Dim sqlDbAdapter1 As New Data.SqlClient.SqlDataAdapter("SELECT COUNT(*) AS myCount FROM dbo.IssueTb ", sqlconn)<br />
sqlDbAdapter.Fill(sqlDataset, "IssueTb")<br />
Dim Issuedv As DataView = sqlDataset.Tables("IssueTb").DefaultView<br />
The above loads a Dataset and DataView with the value but I don't know to bind to the label on the web page.
Databinding used on vb.net was my first try but this was wrong so could someone please help.
Thanks Heaps...
When people make you see red, be thankful your not colour blind.
|
|
|
|
|
Because you are only returning one column in one row you would be better off without the Data Adapter
Dim cmd AS New SqlCommand()
cmd.CommandText = "SELECT COUNT(*) FROM dbo.IssueTb"
cmd.Connection = sqlConn
Dim result As Int32
result = cmd.ExecuteScalar()
...
SomeLabel.Text = result.ToString()
|
|
|
|
|
Thanks Heaps
This worked out great...
When people make you see red, be thankful your not colour blind.
|
|
|
|