|
That's an OLE DB connection string to use the Jet database engine in-process. It won't work for SQL Server.
If you want to connect to SQL Server, use a SQL Server connection string. If you want to use Jet with that connection string, use OleDbConnection.
DoEvents : Generating unexpected recursion since 1991
|
|
|
|
|
<br />
SELECT ID, time, type, ((first + last) * 0.5) AS avg10, (CASE WHEN (a.ID+1) <br />
% 5 = 0 THEN<br />
(SELECT ((c.first + c.last) * 0.5)<br />
FROM a, tmp_ak000002_50 c<br />
WHERE c.ID = (a.ID + 1) / 5 - 1) WHEN a.ID =<br />
(SELECT MAX(a.ID)<br />
FROM a) AND (a.ID + 1) % 5 != 0) THEN<br />
(SELECT ((c.first + c.last) * 0.5)<br />
FROM a, tmp_ak000002_50 c<br />
WHERE c.ID = (a.ID + 1 + 4) / 5 - 1) ELSE NULL END) AS avg50<br />
INTO NewTable<br />
FROM tmp_ak000002_10 a<br />
-- modified at 8:34 Wednesday 28th November, 2007
|
|
|
|
|
SELECT ID, time, type, ((first + last) * 0.5) AS avg10,
( CASE WHEN (a.ID+1) % 5 = 0 THEN
(
SELECT ((c.first + c.last) * 0.5) FROM a, tmp_ak000002_50 c WHERE c.ID = (a.ID + 1) / 5 - 1)
WHEN a.ID = (SELECT MAX(a.ID) FROM a) AND (a.ID + 1) % 5 != 0 THEN
(
SELECT ((c.first + c.last) * 0.5) FROM a, tmp_ak000002_50 c WHERE c.ID = (a.ID + 1 + 4) / 5 - 1)
ELSE NULL END) AS avg50
INTO NewTable
FROM tmp_ak000002_10 a
oops...I didn't see the [solved] in the title....
SG
Cause is effect concealed. Effect is cause revealed.
|
|
|
|
|
i cant solve this problem
adding with this cmd ;
cmdInsert.Parameters.AddWithValue("@RECORD_DATE", DateTime.Today.ToString("dd/MM/yyyy"));
Gettin' this error.
Arithmetic overflow error converting expression to data type datetime.
|
|
|
|
|
What's wrong with:
<br />
cmdInsert.Parameters.AddWithValue("@RECORD_DATE", DateTime.Today);
What data type is record_date?
|
|
|
|
|
oops i found problem.. Problem is my sql command . i was changing datetime.today to string and getting error. thanx for help Paddy Boys .
|
|
|
|
|
there is one small thing
cmd.CommandText = "SELECT KODU,CDISMI,CDTURU,CDADET,ACIKLAMA FROM TBL_PS_2" +
" WHERE RECORD_DATE BETWEEN '" + txtDate1.Text + "' AND '" + txtDate2.Text + "' ";
but getting error about datatype char conversion to datetime bla bla.
|
|
|
|
|
Be careful to send the DateTime-value to the Sql-Server in the right format. If your database-language is set to English(US), maybe you should try to convert the DataTime to this format with a CultureInfo-object.
<br />
CultureInfo ci = new CultureInfo("en-US");<br />
DateTime begin = DateTime.Parse(txtDate1.Text, ci);<br />
DateTime end = DateTime.Parse(txtDate2.Text, ci);<br />
Your SQL-command should then look like this:
cmd.CommandText = "SELECT KODU,CDISMI,CDTURU,CDADET,ACIKLAMA FROM TBL_PS_2" +
" WHERE RECORD_DATE BETWEEN '" + begin.ToString() + "' AND '" + end.ToString() + "' ";
Maybe this solves your problems.
|
|
|
|
|
cmd.CommandText = "SELECT KODU,CDISMI,CDTURU,CDADET,ACIKLAMA FROM TBL_PS_2" +<br />
" WHERE RECORD_DATE BETWEEN '" + txtDate1.Text + "' AND '" + txtDate2.Text + "' ";<br />
Just for your info, that would be subject to dangerous sql injection attacks.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hello Forum!
Here is my problem: I have a table called TblArticle (artnr, comment) and a table called TblArticlemoves (autoid, artnr, quantity, date). Now I need a report that looks like the following example:
artnr ....|01.11.07 | 02.11.07 | 03.11.07 | 04.11.07 | 05.11.07 | ...
A ........| 20 ........| 20 .........| 35.......... | 45 ........| .........15 | ...
B........ | 5 ..........| 15......... |.25 ..........| 5 ......... | ..........20 | ...
.
.
.
The main thing is I need to display each day of a month, but I 'm not having an entry for each day of a month in my table TblArticlemoves. Therefore i need to calculate the stock quantity for each day of the month. How can i do this?
regards adyck
|
|
|
|
|
you can loop through all the days of months and store count of moves in another table.
|
|
|
|
|
u can create a proc with following steps which will return a table..
1) Get no. of days in month. say @no and @p = 1
2) while (@p < @no)
3) Get date and write query GetDate[^]
4> create table with date and count and return it.
Lemme know if it is useful...
|
|
|
|
|
Hello Prateek G,
excuse me, I'm a beginner but
1)what do you mean with @p?
3)can You give me some more hints
4)do You mean selecting the count from TblArticlemoves into a Date table?
Thank You!
Regards adyck
|
|
|
|
|
Doing this with straightforward SQL might get messy and complex. If you're up to it, create a temp table, fill in the days of the month and the stock value and PIVOT it to form the report.
SG
Cause is effect concealed. Effect is cause revealed.
|
|
|
|
|
Hi SG,
I've managed to create a temp table like this:
Dim dt As DataTable = New DataTable("TblDate")
dt.Columns.Add("artnr", Type.GetType("System.String"))
Do While startDate < endDate
dt.Columns.Add((startDate), Type.GetType("System.String"))
startDate = startDate.AddDays(1)
Loop
Now, how do fill in the stock values into the TblDate?
Regards adyck
|
|
|
|
|
I meant a Temp table in SQL Server. Instead of creating a tables with dates as columns, you can use the PIVOT command to prepare your report. PIVOT [^]is easy to master. Just look it up.
SG
Cause is effect concealed. Effect is cause revealed.
|
|
|
|
|
hi all
i have a SQL Query that is like this
<br />
select p1.Property_ID,p1.Lis_key,p1.Func_key,p1.Attrib_code<br />
from sde.property p1<br />
where p1.func_key = 'PV000000'<br />
and exists (select 1<br />
from sde.property p2<br />
where p2.lis_key = p1.lis_key<br />
and substring(p2.func_key,1,5)='GEOSS'<br />
and substring(p1.Attrib_code,3,2)=22<br />
having count(p2.func_key) = 2)<br />
order by Actual_extent Asc<br />
<br />
And this Query works fine, and i want to update the records found by this query above,i tried this
<br />
update sde.property<br />
set Attrib_code = substring(Attrib_code,1,2)+ '10'+ substring(Attrib_code,5,8)<br />
where Exists (select p1.Property_ID,p1.Lis_key,p1.Func_key,p1.Attrib_code<br />
from sde.property p1<br />
where p1.func_key = 'PV000000'<br />
and exists (select 1<br />
from sde.property p2<br />
where p2.lis_key = p1.lis_key<br />
and substring(p2.func_key,1,5)='GEOSS'<br />
and substring(p1.Attrib_code,3,2)=22<br />
having count(p2.func_key) = 2 and <br />
P1.aCTIVE =1))<br />
<br />
The above query will try to execute the whole day, please help me combine the Query to create an update from these update that will update the records found in the first query and please can you explain, so that i can see my mistakes.
<br />
<br />
update sde.property<br />
set Attrib_code = substring(Attrib_code,1,2)+ '10'+ substring(Attrib_code,5,8)<br />
Thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Update p1 set p1.Attrib_code = substring(p1.Attrib_code,1,2)+ '10'+ substring(p1.Attrib_code,5,8)
from sde.property p1
where p1.func_key = 'PV000000'
and exists (select 1
from sde.property p2
where p2.lis_key = p1.lis_key
and substring(p2.func_key,1,5)='GEOSS'
and substring(p1.Attrib_code,3,2)=22
having count(p2.func_key) = 2)
order by Actual_extent Asc
SG
Cause is effect concealed. Effect is cause revealed.
|
|
|
|
|
Thanks man, i have seen my mistake,
you are a star
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Hi
Anyone with a working TSQL string tokenizer? I found this but seems like it's not working and I'm too lazy to debug this.
Thanks
|
|
|
|
|
Twas working when I used a few months back...
CREATE FUNCTION [dbo].[Split](@data NVARCHAR(MAX), @delimiter NVARCHAR(5))
RETURNS @t TABLE (data NVARCHAR(max))
AS
BEGIN
DECLARE @textXML XML;
SELECT @textXML = CAST('<d>' + REPLACE(@data, @delimiter, '</d><d>') + '</d>' AS XML);
INSERT INTO @t(data)
SELECT T.split.value('.', 'nvarchar(max)') AS data
FROM @textXML.nodes('/d') T(split)
RETURN
END
SG
Cause is effect concealed. Effect is cause revealed.
|
|
|
|
|
|
Did you try it? It returns an empty table
select *
from dbo.Split('aaa.bbb.ccc', '.')
|
|
|
|
|
Oops, the last time i pasted the code, <d> was interpreted as HTML.
CREATE FUNCTION [dbo].[Split](@data NVARCHAR(MAX), @delimiter NVARCHAR(5))<br />
RETURNS @t TABLE (data NVARCHAR(max))<br />
AS<br />
BEGIN<br />
<br />
DECLARE @textXML XML;<br />
SELECT @textXML = CAST('<d>' + REPLACE(@data, @delimiter, '</d><d>') + '</d>' AS XML);<br />
<br />
INSERT INTO @t(data)<br />
SELECT T.split.value('.', 'nvarchar(max)') AS data<br />
FROM @textXML.nodes('/d') T(split)<br />
<br />
RETURN<br />
END<br />
<br />
SG
Cause is effect concealed. Effect is cause revealed.
|
|
|
|
|
hi all,
I am working in sql 2005 migration.
when i ran same query in sql 2000 and sql 2005,no of values return are same.But the Resulting data is in different order.
In sql 2005 the data returns either in asc or desc order.
In sql 2000 the data returns in random order.
plz clarify me
1.the reason for the rows order difference.(is it because of execution plan?)
2.The resulting data of sql2005 should be in same order of sql 2000.
how to overcome this problem.
Thanks in advance,
cheers
sangeet
|
|
|
|
|