|
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.
|
|
|
|
|
Hi,
I have the followig table:
Name Data
---- ----
Jim 3
Jim 4
Joe 5
Ann 7
Joe 9
How can I print the names and the number of times they show up? something like
Name Counter
---- -------
Jim 2
Joe 2
Ann 1
second question, how can i print the following?
Name Data
---- ----
Jim 3,4
Joe 5,7
Ann 9
thanx
-- modified at 23:49 Thursday 24th August, 2006
|
|
|
|
|
kozu wrote: How can I print the names and the number of times they show up?
SELECT Name, COUNT(*) AS Counter
FROM MyTable
GROUP BY Name
kozu wrote: second question, how can i print the following?
Printing results of query is something the calling application should be doing.
|
|
|
|
|
Colin answered your first question. Here is a solution for the second:
Make a User Defined Function:
CREATE FUNCTION GetData (@cName varchar(100))
RETURNS varchar(100) AS
BEGIN
DECLARE @nData int
DECLARE @cDataHold varchar(100)
SELECT @cDataHold = ''
DECLARE DataCursor CURSOR FOR
SELECT Data
FROM TestTable
WHERE Name = @cName
OPEN DataCursor
FETCH NEXT FROM DataCursor INTO @nData
WHILE @@FETCH_STATUS = 0
BEGIN
select @cDataHold = @cDataHold + case when len(@cDataHold) > 0 then ', ' else '' end + CAST(@nData as varchar(100))
FETCH NEXT FROM DataCursor INTO @nData
END
CLOSE DataCursor
DEALLOCATE DataCursor
RETURN(@cDataHold)
END
Call it like this:
select name, dbo.getdata(name) as Data from (select distinct name from TestTable) as tbl
--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
|
|
|
|
|
|
I am writing an application that acesses a SQL server, logging on with SQL server authentication and would like to set the menu options acording to the permission the logon user or group has, is there any way of interigating the SQL server for user permissions.
Any help would be appreciated and many thanks in advance
-- modified at 18:00 Thursday 24th August, 2006
|
|
|
|
|
perhaps
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
|
|
|
|
|
I have a column that is a bit. I am looking to Select a row where this column has a null value. I have tried SELECT * From Table Where x = NULL...that doesn't work. When I look at the table through the manager, I see <null> as the value.
How do I program this?
Thank You,
Jude
|
|
|
|
|
TheJudeDude wrote: I have tried SELECT * From Table Where x = NULL...that doesn't work.
SELECT * FROM Table WHERE x IS NULL
|
|
|
|