|
Hi
i am using data base Access 2000.
my code implemnting nestsed transactions where using more then one connection
i get the following exception: "oledbexception:could not update currently locked".
i cant put the whole code but i can demonstrate:
if (!Modified) return;
Modified=false;
OleDbTransaction transaction =null;
try
{
OleDbCommand command = new OleDbCommand();
command.Connection=conn;
transaction=conn.BeginTransaction();
command.Transaction=transaction;
command.CommandType = System.Data.CommandType.Text;
command.CommandText = "Delete * from tab";
command.ExecuteNonQuery();
try
{
OleDbConnection secondCon=GetAnotherConnection();
MyClasss.SaveTo(secondCon,Number)
}
catch(Exception ex)
{
throw new Exception("Can't save " + ex.ToString());
}
MyClasss
{
public void SaveTo(OleDbConnection conn,int Number)
{
OleDbTransaction transaction =null;
try
{
OleDbCommand command = new OleDbCommand();
command.Connection=conn;
transaction=conn.BeginTransaction(System.Data.IsolationLevel.ReadUncommitted);
command.Transaction=transaction;
command.CommandType = System.Data.CommandType.Text;
command.CommandText = "Update [Field Records] " +
" SET " +
"[ Cost Periodic]='" + (periodic?"True":"False") + "';";
command.ExecuteNonQuery();
transaction.Commit();
}
catch(Exception ex)
{
if(transaction!=null)
{
transaction.Rollback();
}
throw new Exception("Can't save" + ex.ToString());
}
}
}
Please give your advice.
Thanks in advance.
|
|
|
|
|
Can anyone help me to save a file in SQL Server 2005.
My application will be used by the user to attach the approval mails (Either html or word or any files).
How can i save and retrive from SQL Server 2005?
Anticipating for your replies...
Regards,
Saranya Balasubramanian
|
|
|
|
|
Use a varbinary(max) column type. Use that type in parameters when you add data to the database. When you select it the result will by a byte array in your .NET application.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
* Reading: Developer Day 5
Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton
My website
|
|
|
|
|
|
I am doing an application in which i have to retrieve data from multiple tables...
the scenario is like this...
a head_quarter table have state field...as numeric
and a state table hav the same fields....as varchar...
i wanna retrieve the data from head quarter table using stored procedures and the numeric id should be returned to a string...
considering the string then i hav to get the name of the state from state table and put it into the web page...
my stored proc is
--Author: SAJAN A PILLAI
--Created: 9:14 AM 6/14/2007 THURSDAY
CREATE PROCEDURE sp_GetCurrentHQ
(@cid numeric , @organization varchar(100), @hqaddr1 varchar(100), @hqaddr2 varchar(100), @hqcity varchar(50), @hqstate numeric, @hqpin varchar(7), @hqdistrict numeric,@hqplace numeric, @hqphone varchar(100), @hqfax varchar(100), @hqemail varchar(100), @hqwebsite varchar(100), @hqpan varchar(50), @hqtan varchar(50), @hqtin varchar(50),
@hqstatetaxno varchar(50), @hqcentraltaxno varchar(50), @hqfromdate datetime, @todate datetime)
AS
BEGIN
declare @state_name as varchar(128);
select @state_name = SHORT_FORM from states where ADM1 = '2';
set @st_name=@state_name;
select OrgName,HqAdd1, HqCity,HqState,HqPin,HqPlace, HqDist, HqPhones ,HqFax,HqEmail,HqWebsite,HqPAN,HqTIN,HqStateTax,HqCentralTax,FromDate,ToDate from HQ where FromDate <= getdate() and ToDate >= getdate();
END
GO
please help me
SAJAN A PILLAI
C#.NET Programmer
TELESOFT INDIA PVT LTD...
BANGALORE
|
|
|
|
|
i have just started learninf SQL 2000
when i mamakin simplest query in query analyzer select * from authors, where authors is the name of table,
its giving error that invalid object ' authors'.
how this error can be resolved???
|
|
|
|
|
1. check the authors tabls exists in the database
2. check whether you selected / pointed the right database
Regards,
Sylvester G
sylvester_g_m@yahoo.com
|
|
|
|
|
manni_n wrote: its giving error that invalid object ' authors'.
how this error can be resolved???
If you are just learning a better question would be "What does the error mean?" so you can understand what it means in the future.
SQL Server has a number of database objects. These include tables, views, stored procedures, functions and so on.
You can get a list of all object in the database by typing
SELECT * FROM sysobjects
The message "invalid object" indicates that the object either does not exist, or it is the wrong type of object for the context in which you are trying to use it.
In this case you refer to a table object in the SELECT statement that does not exist (there may be another object in the system called authors, but that will be a different type of object, or be used in a different context.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
* Reading: Developer Day 5
Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton
My website
|
|
|
|
|
Hi all
i wana come to know that how can i return cursor from a stored procedure???
Regards
Qaiser
|
|
|
|
|
I think A cursor is a server side thing. You can't "return" this to a client.
Anyway why do u need this??
Tirtha
Do not go where the path may lead, go instead where there is no path and leave a trail.
Author: Ralph Waldo Emerson (1803-82), American writer, philosopher, poet, essayist
|
|
|
|
|
Why you need to return a cursor from a Stored Procedure ? I think you got confused with Oracle .. Is it ?
|
|
|
|
|
Hi All
i want to get top 5 records from the table. what would be the query?
Regards
Qaiser
|
|
|
|
|
Returning only the first N records in a SQL query differs quite a bit between database platforms. Here's some samples:
Microsoft SQL Server
SELECT TOP 10 column FROM table
PostgreSQL and MySQL
SELECT column FROM table<br />
LIMIT 10
Oracle
SELECT column FROM table<br />
WHERE ROWNUM <= 10
Sybase
SET rowcount 10<br />
SELECT column FROM table
Firebird
SELECT FIRST 10 column <br />
FROM table
Tirtha
Do not go where the path may lead, go instead where there is no path and leave a trail.
Author: Ralph Waldo Emerson (1803-82), American writer, philosopher, poet, essayist
|
|
|
|
|
I've created a dll (with vb6) to call a webservice, and this works fine when called in vb6.
I need to run this from stored procedure in SQL Server 2000,
because we have many clients that run application that access an SQL server.
It'll be hard work to install the dll into each of the clients pc (and many of them don't have MS SOAP installed), so instead I've been planning to install the dll in the server that runs SQL server, while others clients can just use store procedure to get the result from the webservice (which access to another SQL server machine).
We've tried using linked server but the response is too slow.
When I've tried to create store procedure to access the dll, it always return NULL value.
Anyone can help with this problem?
Thanks in advance,
Chronos
|
|
|
|
|
Have a good day.
Must i create alias and tables on my pc while design and copy them with setup or must i create them in installed pc.
so my real question,
i want to create password protected tables to use but i couldnt create this table in run time.i can do it from database desktop->restructure menu.
İs there anyway to create this table in runtime or make a table which is not protected in c++ and restruct it in c++;
thanks.
|
|
|
|
|
Hi,
I have a stored procedure which is having a input parameter as TEXT datatype. I am passing a string to it whose length is 9000. It does not accept more then 8000 characters of the string. How to solve this issue?
Is there any method in which i can increase the length of the datatype. or is there any other datatype whose datalength is more then 8000?
Thanks,
Riz
|
|
|
|
|
to my knowledge 8000 is max. in SQL Server 2000
Regards
KP
|
|
|
|
|
If you're using classic ADO, you must use the adLongVarChar datatype for the parameter, and use AppendChunk to write the data to the parameter rather than simply assigning the Value property.
For ADO.NET and the SQL Server data provider, use the SqlDbType.Text type.
|
|
|
|
|
Hi,
Thanks for ur reply....
I want to know how exactly to implement it in the stored procedure. Can u give me an example? It's very urgent.
Thanks,
Riz
|
|
|
|
|
Hi i am week in query,
plz solve my probs...,
the following queries,that first query and second query both are working...,
Now my question is,
What are the fields, i am getting in the two queries those want to show in single query...,
Means,in first query ur giving date in that it want to take the year only
and check with tblmonthhourdetails.sdate
and same time the tblmonthhourdetails empid want to equal with the employeemaster.empid
------------------------------------------------------------------
SELECT dbo.tblEmployeeMaster.empId, dbo.tblEmployeeMaster.empName,
dbo.tblTimeCardmain.carddate, dbo.tblTimeCardmain.reportingtime,
dbo.tblTimeCardmain.leavingtime, dbo.tblSalaryDetails.Whrs,
dbo.tblTimeCardmain.shift, dbo.tblTimeCardmain.projectid
FROM dbo.tblEmployeeMaster INNER JOIN dbo.tblTimeCardmain ON
dbo.tblEmployeeMaster.empId = dbo.tblTimeCardmain.empid INNER JOIN
dbo.tblSalaryDetails ON
dbo.tblEmployeeMaster.empId = dbo.tblSalaryDetails.EmpID
WHERE dbo.tblTimeCardmain.carddate = '5/2/2007'
AND dbo.tblTimeCardmain.app1 = 1 AND
dbo.tblTimeCardmain.projectid = 100
-----------------------------------------------------------------------
SELECT SUM(MedicalLeave) AS Ml, SUM(AnnualLeave) AS AL, EmpId
FROM dbo.tblMonthHourDetails
WHERE (DATEPART(YYYY, SDate) = 2007)
GROUP BY EmpId, SDate
-----------------------------------------------------------------------
Plz hlp me...,
-- modified at 1:05 Thursday 14th June, 2007
Magi
|
|
|
|
|
Hi Magi
Try this:
SELECT EM.empId, EM.empName, TC.carddate, TC.reportingtime,
TC.leavingtime, SD.Whrs, TC.shift, TC.projectid,
(SELECT SUM(MedicalLeave) FROM dbo.tblMonthHourDetails MHD
WHERE MHD.EmpId = EM.empId AND YEAR(MHD.SDate) = 2007) AS ML,
(SELECT SUM(AnnualLeave) FROM dbo.tblMonthHourDetails MHD
WHERE MHD.EmpId = EM.empId AND YEAR(MHD.SDate) = 2007) AS AL
FROM dbo.tblEmployeeMaster EM
INNER JOIN dbo.tblTimeCardmain TC
ON EM.empId = TC.empid
INNER JOIN dbo.tblSalaryDetails SD
ON EM.empId = SD.EmpID
WHERE TC.carddate = '5/2/2007'
AND TC.app1 = 1
AND TC.projectid = 100 I have used table aliases (EM, TC, etc) to make your query more readable. Correlated sub-queries are used to get the medical and annual leave.
Regards
Andy
|
|
|
|
|
Thanks lot...,
Its working cool,
Keep in touch,
Take care,
Magi
|
|
|
|
|
Magh_M wrote: Query doubt.
You have a question, not a doubt.
|
|
|
|
|
Hi,
I have one table like
sno name
--- ------
1 hai
2 hello
3 hai
4 hello
5 hello
6 bye
7 take care
from the above table i want to display only duplicate values like
sno name
---- ------
1 hai
2 hello
3 hai
4 hello
5 hello
how to display it ?
|
|
|
|
|
SELECT * FROM tableA WHERE name IN (SELECT name FROM tableA GROUP BY name HAVING Count(*) > 1)
Here Sub-Query retruns only those names which are present more than once and main Query returns all rows where the same is present.
Regards
KP
|
|
|
|
|