|
<u></u>here is my app.config file
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" />
</configSections>
<dataConfiguration defaultDatabase="SqlConnection" />
<connectionStrings>
<add name="SqlConnection" connectionString="server=Developer;database=MSPetShop;Integrated Security=true;"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
first i m getting these two errors:
Message 1 Could not find schema information for the element 'dataConfiguration'.
Message 2 Could not find schema information for the attribute 'defaultDatabase'.
and when i try to call the from my DAL layer i got exception
i m using this funcion
Database db=DatabaseFactory.CreateDatabase();
I hope any one there will reply me many thanks,
adnan
|
|
|
|
|
adnanrafiq wrote: first i m getting these two errors
They are not errors they are messages (it even tells you they are messages). It means that the build process cannot verify if what you have written is valid or not.
adnanrafiq wrote: when i try to call the from my DAL layer i got exception
So, what is the exception? You've just indicated on what line you get the exception without telling us what it was.
|
|
|
|
|
At first glance it looks like the enterprise library is eithe rnot installed or incorrectly installed?
|
|
|
|
|
suppose there are two table called tableA and tableB and the situation is the primary key of tableA is a foreignkey of tableB and the primary key of tableB is a foreignkey of tableA.in this type of situation how we can insert data into 2 tables called tableA,tableB.pls tell me how can i handle this situation very efficiently.explain in detail........plzzzzz.
tbhattacharjee
|
|
|
|
|
Well, I would create a new table say "tableC"(pkA,pkB) which will hold the relation between your two tables and do the insert in it Last. So insert first in Table A then B and last in C.
There are other ways to do it ofcourse...
|
|
|
|
|
Hello,
I am attempting to select all users who are visiting our site with multiple IPAdresses. I wrote the query below but it is not doing what I want it to do. Any assistance in accomplishing this task will be greatly appreciated.
Select UserID from AU_commontable
where UserID IN if exists(Select ipaddress as IP, count (ipaddress )as Total --, userID,logdate
from AU_commontable
where result=1 and actiontaken='firsttimesignon'
group by ipaddress
having (count(ipaddress)>1))
Skan
If you knew it would not compile why didn't you tell me?!?!?!
|
|
|
|
|
select userid,ipaddress, count(1) as[number of unique ipaddress]
from AU_commontable
where result=1
and actiontaken='firsttimesignon'
group by userid,ipaddress
having count(1)>1
|
|
|
|
|
Hi Guys,
I want to compare three columns on each row and get the maximum value. I tried using GREATEST(col1,col2,...) function but it didn't work (I hve SQL version 8.0 installed). Is there any way to get max of several colunms per row? Here is how it should look like.
===========================================================
ID, measurement_01, measurement_02, measurement_03, maximum
===========================================================
1, 300, 350, 325, 350
2, 225, 275, 400, 400
3, 100, 500, 300, 500
===========================================================
I'll appreciate any help
Thanks
-- modified at 16:06 Friday 26th January, 2007
|
|
|
|
|
What database-engine and front-end tool are you using?
|
|
|
|
|
Its SQL server 2000. SQL Query Analayzer version 8.0
|
|
|
|
|
The easiest way (assuming you only need the maximum of 2 columns) would be:
select id, measurement_01, measurement_02, measurement_03,
case
when measurement_01 >= measurement_02 and measurement_01 >= measurement_03
then measurement_01
when measurement_02 >= measurement_03
then measurement_02
else measurement_03
end as maximum
from #temp_ajh
order by id
Regards
Andy
|
|
|
|
|
Or you can flatten the table (as it should have been designed in the first place).
SELECT
m.ID,
m.measurement_01,
m.measurement_02,
m.measurement_03,
MAX (FlatTable.measurement_01)
FROM
MeasurementTable m
INNER JOIN
(SELECT ID, measurement_01
FROM MeasurementTable
UNION
SELECT ID, measurement_02
FROM MeasurementTable
UNION
SELECT ID, measurement_03
FROM MeasurementTable) AS FlatTable
ON (m.ID = FlatTable.ID)
GROUP BY
m.ID,
m.measurement_01,
m.measurement_02,
m.measurement_03
|
|
|
|
|
Both solutions are perfect! Thank you very much for your answer.
-- modified at 17:21 Friday 26th January, 2007
|
|
|
|
|
How can i crate aint value that will display the value as 0001 to 9999
without omitting the zeroes
Thanks
javierarka
|
|
|
|
|
In SQL-Server:
set @myString = Right('0000' + Convert(varchar(4), @MaxKey), 4)
In VbScript:
myString = Right("0000" & intNumber, 4)
|
|
|
|
|
I need to create a Column id in my table.
This Column ID has to be a 'sa0200701260001' where sa0 is a value i give to it 20070126 is the current date and 0001 is a number that will increment everytime this statement is called
can somebody tell me how can i make this incrmented value.
Thanks
Javierarka
|
|
|
|
|
Which database engine are you using? If you were using a SQL-Server stored procedure then the code would look something like:
create procedure MyRecordInsert
@Prefix varchar(3),
@OtherData varchar(20)
as begin
set nocount on
declare @PrimaryKey varchar(15), @MaxKey int
Begin tran
--Create first part of primary key (prefix + date).
set @PrimaryKey = @Prefix + Convert(varchar(8), GetDate(), 112)
--Find the higher number that has been allocated today.
--Use locking to prevent anyone else inserting until we have finished
--our transaction.
select @MaxKey = Convert(Int, Substring(Max(PrimaryKey), 12, 4))
from MyTable with (tablock, holdlock)
where PrimaryKey like @PrimaryKey + '%'
--Increment the highest number, and then append to key.
set @MaxKey = IsNull(@MaxKey, 0) + 1
set @PrimaryKey = PrimaryKey +
Right('0000' + Convert(varchar(4), @MaxKey), 4)
--Insert record into the database.
insert into MyTable (PrimaryKey, OtherData)
values (@PrimaryKey, @OtherData
Commit tran
end You will need to add some error handling. The general approach is valid for other database engines (although the syntax would obviously be different). The combination of a transaction and locks should allow you to allocate new keys without clashing with other users. If you only have a small number of users then you might be able to get away with a simpler approach.
Hope this is helpful.
Andy
|
|
|
|
|
You could always do it using something like this:
INSERT INTO myTable(ID, Item1, Item2)
SELECT 'sa0' + CONVERT(DATETIME, GETDATE(), 112) + COUNT(*),
@Item1, @Item2
FROM myTable
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
This thing bother me some time already
Say I have form that should display data about some student; one of thing it need to display is cityID which is just foreign key to some city in table city.
How can I make it display name of city instead of ID, but write ID to table student.
I tried to do this logical way but never worked, first if there is some data in base it'll show FK value instead on city name, second when I drop down list I get names of cities, but when I pick one from list I never can continue even though I selected value member as ID field not name field (in parent table).
I tried any combination available still doesn't work as expected.
all data is show in details mode and combo box is for cityID value...
Any idea?
|
|
|
|
|
Hi All,
I am trying to run an update query from Oracle SQL Plus, I need to change a reference ID (in table Equipment) from A to B where the ContractID (in table Contract) is 1234, however the link between Contract table and Equipment is done through 2 other tables, the query is:
UPDATE EQUIPMENT SET REF_ID = ‘B’
WHERE EXISTS
(SELECT CONTRACT.CONTRACT_ID, EQUIPMENT.REF_ID
FROM ((CONTRACT LEFT JOIN CONTRACT_PERIOD ON CONTRACT.CONTRACT_ID = CONTRACT_PERIOD.CONTRACT_ID) LEFT JOIN CONTRACT_EQUIP_PERIOD ON CONTRACT_PERIOD.CONTRACT_PERIODOID = CONTRACT_EQUIP_PERIOD.CONTRACT_PERIODOID) LEFT JOIN EQUIPMENT ON CONTRACT_EQUIP_PERIOD.EQUIPMENTOID = EQUIPMENT.EQUIPMENTOID
WHERE (((CONTRACT.CONTRACT_ID)=’1234’) AND ((EQUIPMENT. REF_ID)=’A’)));
when I run this query the rather than change 2 records, it changes about 233,000 of them (Good things I'm using the test Database)
If you could tell me where I'm going wrong, I would really appreciate it.
Many thanks
Sayian
Ignorance is darkness.
Knowledge is light.
|
|
|
|
|
I think you need the following:
UPDATE EQUIPMENT SET REF_ID = ‘B’
WHERE EQUIPMENTOID IN (
SELECT CONTRACT_EQUIP_PERIOD.EQUIPMENTOID
FROM CONTRACT
LEFT JOIN CONTRACT_PERIOD
ON CONTRACT.CONTRACT_ID = CONTRACT_PERIOD.CONTRACT_ID
LEFT JOIN CONTRACT_EQUIP_PERIOD
ON CONTRACT_PERIOD.CONTRACT_PERIODOID = CONTRACT_EQUIP_PERIOD.CONTRACT_PERIODOID
WHERE CONTRACT.CONTRACT_ID = 1234
)
AND EQUIPMENT.REF_ID= 'A' ; Your original SQL was saying "Do any equipment rows exist for the criteria? Right now update everything single equipment record!"
Regards
Andy
|
|
|
|
|
I need to grab data from a table not in my database.
The other database is on the Ms SQL server.
Now I know how to access it, but I was just thinking what would be the best method for accessing the data.
First I was thinks about just working with the tables in the other database and using sored procedures to insert and access the data.
The second option is to make views to the other database and use them as if there locale tables.
The second option makes it easy to make any change later, but this probably not happen and I could just act a an overhead.
Anyone a pointers on the best way to do this?
|
|
|
|
|
How can i convert a getdate() result to a style of yyyymmddhhmmss
Thanks
Javierarka
|
|
|
|
|
select replace(convert(varchar(10), GetDate(), 112) + convert(varchar(8), GetDate(), 114), ':', '')
Regards
Andy
|
|
|
|
|
select replace(replace(replace(convert(varchar(19),getdate(),120),'-',''),':',''),' ','')
|
|
|
|
|