|
SELECT TOP 1 * FROM table WHERE condition ORDER BY productdata DESC
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
Thanks for for that too Colin
Everything & Nothing
http://www.lostsheep.com
|
|
|
|
|
I'm accessing Oracle data using oo4o VB. Here's the problem:
I'd like to update the unique keys like below. How would I
implement it using oo40 oradynaset. If it can't be done,
how to implement it in ADO?
Ukey (Original -> Target Data)
----
10 -> 11
11 -> 12
12 -> 10
Have tried it but there's a unique key violation error
after I call the Oradynaset.Update method for each row.
I use begintrans/committrans.
|
|
|
|
|
I am a little unclear about why you would be doing this from code. Updating primary keys should never be a part of an application, unless it is a one-time fixup of data.
That said, the problem is that the database will not allow 2 items to share a primary key value, even within a transaction. So, the solution would be do it in two steps, e.g.
Step 1
<br />
10 -> 1011<br />
11 -> 1012<br />
12 -> 1010
Step 2
<br />
1011 -> 11<br />
1012 -> 12<br />
1010 -> 10<br />
You could still keep the above in a single transaction.
|
|
|
|
|
Now the database I have has relationships defined through the tables, albiet the design is more implied in the design of the fields and tables. Realizing that MS Access is nothing more than a front end to the Jet Database, is it worth it to setup relationships in MS Access through the Tools/Relationships menu option? That is, it seems in using this menu option it shows subsheets for the tables that have relationships and perhaps you have a design look and feel in the Relationship window, but on a programmical scale is it worth setting this up? What are the benefits in using that menu option?
Thanks!
|
|
|
|
|
Hi there. I would say yes, establish relationships using the front-end provided by Access. Jet will enforce those relationships, and you would rather have the database engine itself enforce data integrity than to code for it in an application.
|
|
|
|
|
I want to Learn Mysql Databse is there andy body who can help me in this regard
Thanks
Jawed
|
|
|
|
|
Try to get the this books "PHP/MySql Programming for the absolute beginner" its ISBN is: 1-931841-32-2. You can purchase it from Amazon.com or use google to search for PHP documentation over the internet.
Roath Kanel
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
|
Hi pls let me know anybody how to insert Photo into database and how to display in webpart using C#.
sree
|
|
|
|
|
If I INSERT data into a table 'table_1' from my C++ application and want the SQL Server to INSERT portions of data from 'table_1' into 'table_2' and 'table_3', how do I solve that in a correct way? Do I have to do INSERR from my C++ application into 'table_2' and 'table_3' or is there a better way to let the SQL Server handle that??
KT
|
|
|
|
|
Put an insert trigger on table_1.
With in the trigger do the insert into table_2 & table_3.
Michael
I firmly believe that any man's finest hour, the greatest fulfillment of all that he holds dear, is that moment when he has worked his heart out in a good cause and lies exhausted on the field of battle - victorious.
Vince Lombardi (1913-1970)
|
|
|
|
|
Thank you for your answer. I will try that...
|
|
|
|
|
Hello, I'm new at this tables. I'm getting into this microsoft sql server enterprise manager, and I have on my database 50 or more tables. looking for a keyboard shortcuts for this tool. anyone knows?
|
|
|
|
|
In Enterprise Manager, go to the help menu. Then see Accessibility for MMC.
HTH,
Thea
|
|
|
|
|
Ok, I have been mapping DataColumns to DataParameters for a while, and getting great results with output Parameters! All of the sudden, it doesn't work anymore!!! WHY!!!???
Can anyone point me into the direction of where to look for troublesome code?
P.S.
No, I cannot supply any code...
|
|
|
|
|
I am using SQL 2K and C#. I want to keep all the database manipulation code at the db itself and so i decided to use Stored Procedures. Now when i tried to use Stored Procs with parameters, i find that i have to supply the datatype as well as the data length when i create the Parameter.
***************************************
SqlParameter parm = new SqlParameter();
parm.ParameterName = "@employeeName";
parm.DbType = DbType.Varchar;
parm.Size = 50;
parm.Direction = ParameterDirection.Input;
cmd.Parameters.Add(parm);
**************************************
Doesn't this DEFEAT the whole purpose(keeping the code independent from database) of using stored procedures This means if i change the size of a parameter in the database, i have to modify my c# code and recompile. Am i missing something or is this the only way to do it?
|
|
|
|
|
There are ways to query the DB to set up the parameters for you unfortunatly, it is much slower.
It is a pain to deal with parameter size changes but, if your DB design is well thought out it becomes a very minor issue over time.
This is really no different than coding your own SQL statements at the client. If you changed a column size and passed in data the exceeds it, SQL will throw an error and you will have to change your client code. Knowing your data size limits at compile time is a good thing.
|
|
|
|
|
I work in VB.NET but I guess, ADO.NET must be same in C#. So, here is how we use DB procedures for data handling.
We have some SQL Helper classes defined parallel to Data.SQLClient methods. These methods will discover the parameters of the procedures at runtime using SQLCommandBuilder.DeriveParameters. This gives us the current parameter information of Procedures we have in DB.Though it is a bit slow, we will have current parameter collection information. If size of a parameter in underlying SP is changed this method will have it too. So, while referencing this method, we dont have to mention datatype or size of parameters.
This works fine without changing the client or recompiling, as long as the singnature of SP is not changed. Else obviously we have to change the code in the client application.
Bhaskara
|
|
|
|
|
Tadaaaaa!
Select Parameter_Name, Parameter_Mode, Data_Type, Character_Maximum_Length, SysTypes.Length
From Information_Schema.Parameters
Inner Join SysTypes ON Information_Schema.Parameters.DATA_TYPE = SysTypes.Name
Where Specific_Name = '[Sotred Proc Name]'
It's fast and efficient...
|
|
|
|
|
There are very few reasons to go with stored procedures at all. The possible valid reasons are:
* better database security
* allows dba to have better control
The invalid reasons are:
* speed (minimal at best, occasionally worse)
* keeping code independent of the database (it does the opposite by locking you into a db vendor)
* strongly typed parameters (you can do this with normal queries)
Good reasons not to do it are:
* hides business logic away
* SQL expertees required to maintain
* difficult to write search queries
* locks you into a specific database vendor
* adds another level of complexity to your app
Actually, for a new application, there is very little need to write any data access code at all. I use Codesmith to generate my data access code just the way I like it.
|
|
|
|
|
For input parameters you don't need to set the length or the type...
SqlCommand cmd = ...;
cmd.Parameters.Add("@ParamName", obj);
Have a look at my latest article about Object Prevalence with Bamboo Prevalence.
|
|
|
|
|
i don't know if this is the right place to post this, but is database related so i hope someone can help me ...
!!! all this is done in vc++ 6.0 using MFC/DAO !!!
i have a database with a table that has one numeric field called ID...
in my program, i assign a string to every value of this field...
so if the table has the following data
1
3
2
1
2
then my data will be in the following form
cow
chicken
wolf
cow
wolf
that is, every number has an assigned string.
the problem is that i want to store only the numeric field in the table and do all the processing in the program
so how can i have a recordset that contains the strings and to be able to sort it ?
another example :
i have a table that contains two fields : DATE and TEXT
but i want to have in my program three fields : DATE, TIME, and TEXT, where DATE and TIME is extracted from the DATE field in the database.
also i want to be able to sort by DATE or TIME in my program, so a database with folowing data
DATE TEXT
---------------- -----------
15/02/2001 12:28 Chris
19/02/2002 15:42 George
25/07/2003 09:48 John
will show up like this in my program
DATE TIME TEXT
---------- ----- -----------
15/02/2001 12:28 Chris
19/02/2002 15:42 George
25/07/2003 09:48 John
and i should be able to sort by DATE, or TIME, or TEXT
i'm showing data using a CListCtrl (not virtual)
please can somebody help me up with this ?
thanks ! (at least for reading this)
|
|
|
|
|
i've tried to do build a table and then deleting it when the database is closed but that is how far i am...
i'm not too good at SQL and i don't know if i can do this in MFC/DAO
so please......
|
|
|
|
|
The database load command has two functions:
1) It will be used to populate database tables from CSV files
2) It will be used to update database tables from CSV files
The command might be run in Sun Solaris (sparc) or in Windows 2000
machine. We are assuming that will not get local access to their database
server, the access is probably happen over JDBC or/and ODBC.
Database will be Microsoft SQL Server 2000 SP3.
Please note that a updated CSV file will be loaded to the database
once a month (the function 2) above). The load command should
not duplicate existing rows in tables, and it should not cause
production downtime, i.e. it must not just delete all existing rows
(or drop existing table) and create all rows from scratch as
that kind of update would cause production downtime.
I have included few lines from beginning of two of the CSV files.
As you can see, the first line in CSV file lists the column names.
The corresponding database tables will have same column names to
make things easier. All columns won’t be VARCHARs, some
of them will be floating point numbers (longitude and latitude must
be floating point numbers in the tables).
--- postalcode.csv ---
"POSTAL_CODE","CITY","PROVINCE","PROVINCE_ABBR","AREA_CODE","CITY_FLAG","TIME_ZONE","DAY_LIGHT_SAVING","LATITUDE","LONGITUDE"
"A0A 1A0","AQUAFORTE","NEWFOUNDLAND","NF","709","N","3.5","Y","47.007050","-52.95195"
"A0A 1B0","AVONDALE","NEWFOUNDLAND","NF","709","N","3.5","Y","47.416880","-53.19755"
"A0A 1C0","BAY BULLS","NEWFOUNDLAND","NF","709","N","3.5","Y","47.321210","-52.81743"
"A0A 1E0","BAY DE VERDE","NEWFOUNDLAND","NF","709","N","3.5","Y","48.086930","-52.89581"
--- postalcode.csv ---
--- zipcode.csv ---
"ZIP_CODE","CITY","STATE","AREA_CODE","CITY_ALIAS_NAME","CITY_ALIAS_ABBR","CITY_TYPE","COUNTY_NAME","COUNTY_FIPS","TIME_ZONE","DAY_LIGHT_SAVING","LATITUDE","LONGITUDE","ELEVATION"
"00501","HOLTSVILLE","NY","516","I R S SERVICE CENTER","","N","SUFFOLK","103","5","Y","40.81518","-73.0455","25"
"00501","HOLTSVILLE","NY","516","HOLTSVILLE","","P","SUFFOLK","103","5","Y","40.81518","-73.0455","25"
--- zipcode.csv ---
dadsadasd
|
|
|
|
|