|
reza assar wrote: yes i think there is no any connection object in the pool " and database-server doesn't accept any new incoming connections" and it does not allow establish a new fresh connection but after restarting the client computer everything working ok!
Sounds like you got some connections that don't get closed/disposed properly. Any code that could leak connections/readers?
I are Troll
|
|
|
|
|
thanks Eddy
yes maybe .
i will check it and fix it (if there is any) and get the result back hear.
any other suggestion?
|
|
|
|
|
reza assar wrote: any other suggestion?
It might speed up things if you search (Ctrl-F) the entire solution for "SqlConnection" and add a using-block to each instance found. That would, in theory, dispose of your connection once processing exits the defined scope, and thus, also close it.
I are Troll
|
|
|
|
|
there are a series of time based data, every 15 mins 1 record:
Time Value
00:15 10
00:30 11
00:45 9
01:00 21
01:15 18
01:30 20
01:45 19
02:00 15
02:15 13
02:30 15
02:45 14
03:00 12
03:15 22
03:30 20
03:45 21
04:00 19
...
...
...
how to get the records that maintains over 18 for over 30 mins?
for example, for 01:00 it starts to be over 18, and maintains for over 30 mins, so 01:00 should be chosen, but 01:15,01:30 should not, because the time difference between them and 01:00 is less than 30 mins,and even 01:45 should not be chosen, because no values are over 18 and maintains for 30 mins.
Regards,
unruledboy_at_gmail_dot_com
http://www.xnlab.com
|
|
|
|
|
here is an idea: join the table to itself, and set appropriate conditions.
in pseudo-SQL-code:
SELECT a.time,a.value,b.value,c.value FROM table as a
JOIN table as b ON b.time=a.time+15minutes
JOIN table as c ON c.time=b.time+15minutes
WHERE a.value>=18 AND b.value>=18 AND c.value>=18
You'll have to work out the details yourself.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
With this approach you could use any over(18) and duration(30) values.
select time, value from (
select *,
(select count(time) from @temp t2 where t2.time > t1.time and t2.time <= dateadd(mi, 30, t1.time)) as reccount,
(select count(time) from @temp t2 where t2.value >= 18 and t2.time > t1.time and t2.time <= dateadd(mi, 30, t1.time)) as okcount
from @temp t1
where value > 18
) t
where t.reccount = t.okcount
|
|
|
|
|
Here is a snippet of my stored proc:
Insert into users
(
firstName,
middleName,
lastName,
sex,
entryDate,
modifyDate,
modifyUser,
locID,
deptID,
contactID,
authenticationID,
userLevelID
)
Values
(
@firstName,
@middleName,
@lastName,
@sex,
getDate(),
getDate(),
@modifyUser,
@locID,
@deptID,
@contactID,
@authenticationID,
@userLevelID
);
set @userID = Scope_Identity();
return @userID;
This runs fine and inserts my users, but in my code I have this:
conn.Open()
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@firstName", Server.HtmlEncode(txtFirstName.Text.Trim))
cmd.Parameters.AddWithValue("@middleName", Server.HtmlEncode(txtMiddleName.Text.Trim))
cmd.Parameters.AddWithValue("@lastName", Server.HtmlEncode(txtLastName.Text.Trim))
cmd.Parameters.AddWithValue("@sex", dropSex.SelectedValue.ToString)
cmd.Parameters.AddWithValue("@locID", "1")
cmd.Parameters.AddWithValue("@userLevelID", "10")
cmd.Parameters.AddWithValue("@deptID", "1")
cmd.Parameters.AddWithValue("@hash", strHash)
cmd.Parameters.AddWithValue("@salt", strSalt)
cmd.Parameters.AddWithValue("@ssn", txtSSN.Text.Trim)
cmd.Parameters.AddWithValue("@street", Server.HtmlEncode(txtStreet.Text.Trim))
cmd.Parameters.AddWithValue("@city", Server.HtmlEncode(txtCity.Text.Trim))
cmd.Parameters.AddWithValue("@stateID", dropStates.SelectedValue.ToString)
cmd.Parameters.AddWithValue("@zip", txtZip.Text.Trim)
If txtPhone.Text.Length > 0 Then
cmd.Parameters.AddWithValue("@phone", txtPhone.Text.Trim)
Else
cmd.Parameters.AddWithValue("@phone", DBNull.Value)
End If
If txtCell.Text.Trim.Length > 0 Then
cmd.Parameters.AddWithValue("@cell", txtCell.Text.Trim)
Else
cmd.Parameters.AddWithValue("@cell", DBNull.Value)
End If
If txtPhone2.Text.Trim.Length > 0 Then
cmd.Parameters.AddWithValue("@phone2", txtPhone2.Text.Trim)
Else
cmd.Parameters.AddWithValue("@phone2", DBNull.Value)
End If
cmd.Parameters.AddWithValue("@userName", txtUserName.Text.Trim)
cmd.Parameters.AddWithValue("@modifyUser", DBNull.Value)
Dim userID As Integer = cmd.ExecuteScalar
Session("userID") = userID
But, I never get the userID from the database. What am I doing wrong?
|
|
|
|
|
Hi,
ExecuteScalar returns the first column from the first row in the result set. The userID isn't a result set but a return value. So you have to define one more parameter for the return value. For this parameter define the direction as ParameterDirection.Input . For examples see: http://support.microsoft.com/default.aspx?scid=kb;en-us;308049[^]
Side note: If your procedure isn't actually returning a result set you could use ExecuteNonQuery instead of ExecuteScalar for performance reasons.
|
|
|
|
|
Change this line
set @userID = Scope_Identity();
to
set @userID = Scope_Identity();
Select @UserID as UserID
As Mika suggested you are not returning a result dataset and @UserID is not an out parameter so the value is being ethered.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi All,
I am using Oracle Transaction for getting records from Oracle 11g from my .net Application while retreiving the records I am getting the error, ORA-08177 can't serialize access for this transaction error.
How can this problem be solved from transactions while using in .net Application.
Thanks.
|
|
|
|
|
Hi,
There are several possible reasons for this. Beasically the problem is that when the transaction is run in SERIALIZABLE mode some data change has been encountered so the transaction fails. If READ COMMMITTED would have been used the data would have been gotten based on SCN's and undo information. Few things you could check:
- are triggers involved
- do you have autonomus transactions
- is the SERIALIZABLE mode hte isolation level you really want to use
|
|
|
|
|
Hi,
Thanks for reply.I am using the Serializable mode but there no autonomus transactions and triggers.But, there are only multiple queries like first there is an insertion in a table, then deletion from the same table and then selection from other tables and so on.
Also, while doing a new transaction the connection is reopened every time with the Oracle.
Thanks.
|
|
|
|
|
As this is a concurrency problem it's kinda hard pointing out the problem without seeing the whole scenario. However to demonstrate the problem, do the following:
1. Create a test table and insert data into it
CREATE TABLE Test (
a NUMBER PRIMARY KEY NOT NULL
);
INSERT INTO Test VALUES (1);
COMMIT;
2. Now in this session start a transaction and delete the rows. Leave the transaction open
ALTER SESSION SET ISOLATION_LEVEL=SERIALIZABLE;
DELETE FROM Test;
3. Start another session and select data from the test table in serializable mode
ALTER SESSION SET ISOLATION_LEVEL=SERIALIZABLE;
SELECT a FROM Test FOR UPDATE OF a; 4. The session 2 hangs and waits for the result from session 1. Now go back to session 1 and commit the transaction:
COMMIT;
The result in session 2 is:
SELECT a FROM Test FOR UPDATE OF a
*
ERROR at line 1:
ORA-08177: can't serialize access for this transaction
Hopefully this clarifies the problem.
Best regards,
mika
|
|
|
|
|
Let's say I have five sheets in excel workbook,and each sheet contains one table.Is there any way to Import only active sheet to my C#,What should I do to recognize only active sheet.??any help,ideas??
One more thing,How can I get a dato to C# from Excel VBA control(let's say textbox),
So i have vba control textbox in sheet and i want to get that textBox.value in my c# project??
|
|
|
|
|
You've posted in the wrong forum so are unlikely to get an answer: try moving to the C# forum.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
nils illegitimus carborundum
me, me, me
|
|
|
|
|
I've moved,thank you,But I cant delete this message here cuz you replied.
|
|
|
|
|
I wouldn't worry about it: the fact that you've done it is enough.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
nils illegitimus carborundum
me, me, me
|
|
|
|
|
hi..
this is my SP
USE [TASKDB]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[GetCmtRpt]
-- Add the parameters for the stored procedure here
@logid int
AS
BEGIN
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT Date ,From_Name ,To_Name ,Todays_Task ,Tommorrows_Task ,Status,Comments,Date as months
from TaskSheet inner join
login on TaskSheet .loginID = login.loginID
where login.loginID = @logid
order by Date desc
END
i want to display the months field as jan feb mar based on date how to do...?
|
|
|
|
|
Here it is:
SELECT substring(DATENAME(month, getdate()),1,3) AS MonthName
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
Dear All,
I have a report with a listbox of 5 coloumns, this report is loaded with a lot of records (600 rec). when the report is loads (in print priview) records beyond the length of the listbox are not shown.
how to make the report pages increase (multipage) and the listbox espand automaticaly as much as the number of records ??
Any Report control i can use so i can show all records returned from the query ??
Thanks
0 will always beats the 1.
modified on Wednesday, February 23, 2011 1:23 AM
|
|
|
|
|
hi..
The following is my Sp
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[GettomoTaskSheet]
-- Add the parameters for the stored procedure here
@fname nvarchar(50)
AS
BEGIN
SET NOCOUNT ON;
SELECT date,To_Name ,Todays_Task,Status ,Tommorrows_Task,REPLACE(Comments, 'vinni','<font color="red">raki</font>') as comment
from TaskSheet where From_Name = @fname;
END
The above SP is used for displaying the data in SSRS reports ..
but when i run the SP in comment field where vinni occurs
i want raki in red color but it is displaying <font color="red">raki</font> this value.
i want to display the word raki in red color in ssrs2008 reports
please help me..
|
|
|
|
|
You are putting UI processing in the database query, wrong tool for the job. The data is interpreted as a string literal.
Move your UI code to RSS, there is a function area where you can put in the code to do that.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I am having problems with executing a command object in ADO. The specific problem I have revolves around the proper type for the SQL string. Following examples on the internet, I established it with a _bstr_t. This though is not working with the * VARIANT type that is required in the Execute method. Can someone help me with the proper establishment of the SQL string? Listed below is the complete program:
Here is my error message coming out of the try block:
error C2664: 'ADODB::Command15::Execute' : cannot convert parameter 1 from '_bstr_t' to 'VARIANT *'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
#include <stdio.h>
#include <string>
using std::string;
int cyc = 0;
#import "c:\program files\common files\system\ado\msado15.dll" rename ("EOF","EOFile")
using namespace std;
struct StartOLEProcess{
StartOLEProcess( ) {
::CoInitialize(NULL);
}
~StartOLEProcess( ) {
::CoUninitialize( );
}
} _start_StartOLEProcess;
void main(void)
{
ADODB::_ConnectionPtr con = NULL;
ADODB::_RecordsetPtr rec = NULL;
ADODB::_CommandPtr com = NULL;
ADODB::_ParameterPtr par = NULL;
bstr_t sConString;
bstr_t sSQLString;
HRESULT hr = S_OK;
VARIANT *vRecordsAffected = NULL;
hr = con.CreateInstance(__uuidof(ADODB::Connection));
hr = com.CreateInstance(__uuidof(ADODB::Command));
hr = par.CreateInstance(__uuidof(ADODB::Parameter));
hr = rec.CreateInstance(__uuidof(ADODB::Record));
printf("Connection object created.\n");
sConString = L"Provider=Microsoft.Jet.OLEDB.4.0;"
L"Data Source=C:\\Users\\Mike Certini\\Documents\\Trading\\Databases\\TradingAnalysis#2.mdb";
hr = con->Open(sConString, L"", L"", -1);
printf("Connection has been opened.\n");
_bstr_t strSQL("INSERT INTO mytable(id,desc)");
com->ActiveConnection = con;
com->CommandText = strSQL;
com->CommandType = ADODB::adCmdStoredProc;
VARIANT vtInt;
int intNum = 1;
vtInt.vt = VT_I2;
vtInt.iVal = intNum;
VARIANT vText;
vText.vt = VT_BSTR;
vText.bstrVal = _bstr_t("This is text");
hr = com->Parameters->Append(com->CreateParameter(_bstr_t("id"),ADODB::adInteger,ADODB::adParamInput,4,intNum));
hr = com->Parameters->Append(com->CreateParameter(_bstr_t("desc"),ADODB::adChar,ADODB::adParamInput,15,vText));
try
{
rec = com->Execute(strSQL, NULL, ADODB::adCmdStoredProc);
}
catch(_com_error &e)
{
_bstr_t bstrSource(e.Source());
_bstr_t bstrDescription(e.Description());
printf("Error\n");
printf("\tCode = %08lx\n", e.Error());
printf("\tCode meaning = %s\n", e.ErrorMessage());
printf("\tSource = %s\n", (LPCSTR) bstrSource);
printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
rec->Close( );
rec = NULL;
printf("Closed an removed the "
"Recordset object from memory.\n");
con->Close( );
con = NULL;
printf("Closed and removed the "
"Connection object from memory.\n");
}
|
|
|
|
|
Hi,
Few observations:
- your command type shouldn't be adCmdStoredProc since you're executing a normal DML statement. Use adCmdText instead.
- the SQL statement for insert should contain the VALUES section and the parameters to use, like:
_bstr_t strSQL("INSERT INTO mytable(id,desc) VALUES (?, ?)");
- the execute contains the SQL statement as a parameter. I'm not sure if there's such overload, normally the first parameter is the number of records affected, see: http://msdn.microsoft.com/en-us/library/ms681559(VS.85).aspx[^]
|
|
|
|
|
Mika,
Thank you for your response. After making the changes you suggested I get the following error. Instead of the "Records Affected" parameter, I have input "NULL". As a result, I am getting this error:
Connection object created.
Connection has been opened.
Error
Code = 80040e14
Code meaning = I
Source = Microsoft JET Database Engine
Description = Expected query name after EXECUTE.
|
|
|
|
|