Skip to content

Database

Discussions on database access, SQL, and ADO

This category can be followed from the open social web via the handle database@forum.codeproject.com

17.1k Topics 61.8k Posts
  • Which Database to Use

    database
    15
    0 Votes
    15 Posts
    0 Views
    L
    You're welcome :)
  • 0 Votes
    2 Posts
    0 Views
    W
    Hi, You can use BackgroundColor-property to change the color and define an expression how the color is set. What comes to the color itself, you can for example resolve the color in the formula or add an extra field to your query which defines the color, like: SELECT ... CASE WHEN LOWER(table.NameField) LIKE '%john%' THEN 'Red' WHEN LOWER(table.NameField) LIKE '%steve%' THEN 'Blue' ... ELSE 'White' END AS BackgroundColor, ... FROM ... Now each row should have a color field which you can use in the expression for the BackgroundColor-property. If you want to do this in more elegant way you can create a table for the name/color pairs and use that table for lookups and possibly create a small T-SQL function for the logic. The need to optimize rises from a bad design.My articles[^]
  • Insert Record into Access

    database perl help tutorial question
    6
    0 Votes
    6 Posts
    0 Views
    B
    Thanks Mika. As both you and Luc suggested, using AS worked by referencing the existing ID's. I'd much rather not do it that way but when I try to insert a record with no ID my table does not update. I'll try to figure that out latter since I can get by with Aliasing for now. ;)
  • 0 Votes
    2 Posts
    0 Views
    W
    Hi, One way of doing this could be: select * from orders a where a.customer = 'A' and ( a.id in (select top(2) id from orders b where b.customer = a.customer and b.id < 26 order by b.id desc) or a.id in (select top(3) id from orders b where b.customer = a.customer and b.id >= 26 order by b.id asc)) The above (not tested) should fetch 5 rows. ID 26 and 2 rows from both sides The need to optimize rises from a bad design.My articles[^]
  • Have you seen a sql tool? [modified]

    database question announcement
    15
    0 Votes
    15 Posts
    0 Views
    F
    I've seen lots of tools make attempts at using sql, but in response to your question all you have to do is wrap the generated sql in a create procedure call, add parameters and voila, you have your skeleton procedure. Of course I believe that all procedures should do whatever they can to protect the data so I insist that any procedures written on my watch contain validation of whatever can be validated. I wasn't, now I am, then I won't be anymore.
  • query problem

    database help
    8
    0 Votes
    8 Posts
    0 Views
    L
    SayamiSuchi wrote: no i tried both only string literals need quotes. numeric literals don't. SayamiSuchi wrote: is it possible to ... yes, of course. add a record that has id=67 and file="pqr", then try select Name from data where id=67 and file like 'p%' :) 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.
  • Updating a table from Excel

    database question css discussion announcement
    2
    0 Votes
    2 Posts
    0 Views
    W
    Hi, It's been years since I last used DAO but few things come in mind: - The statement executed using CDaoRecordSet is (if I recall correctly) parsed by the provider. This actually means that your DAO provider should be able to understand the SQL syntax you use, but that's not possible (since you're using T-SQL syntax) - Unfortunately CDaoRecordSet doesn't have the capability to pass the statement to the server as-it-is - You could try to use CDaoQueryDef instead and use the passthrough option so that the provider won't interfere. After all you're not trying to get any results back to the client but to populate a table in the database Also keep in mind that in your statement you're referring to a file which resides on the database server. Meaning that the file xltest.xls must reside in directory C:\test at the database server. The need to optimize rises from a bad design.My articles[^]
  • Oracle cursor

    oracle
    2
    0 Votes
    2 Posts
    0 Views
    W
    Hi, you can use cursor%FOUND to see if the cursor has a row but better yet you can define a for loop for a SQL statement. For example: for MyList in (SELECT Name FROM Emp) loop ... end loop; The need to optimize rises from a bad design.My articles[^]
  • RollBack Process

    database sql-server sysadmin question
    3
    0 Votes
    3 Posts
    0 Views
    W
    Hi, If you mean that can you rollback the truncation of a table if it's done in a tranaction: Yes. You can test this with a small test case: -- Table creation and filling CREATE TABLE TruncTest ( Column1 int); BEGIN DECLARE @cnt INT; SET @cnt = 0; WHILE @cnt < 100 BEGIN INSERT INTO TruncTest VALUES (@cnt); SET @cnt = @cnt + 1; END; END; SELECT COUNT(*) AS Rows FROM TruncTest; -- Result: -- Rows -- 100 --test truncation BEGIN TRANSACTION; TRUNCATE TABLE TruncTest; SELECT COUNT(*) AS Rows FROM TruncTest; -- Result: -- Rows -- 0 ROLLBACK; SELECT COUNT(*) AS Rows FROM TruncTest; -- Result: -- Rows -- 100
  • Strnge WHERE syntax

    database com question
    6
    0 Votes
    6 Posts
    0 Views
    J
    Run the following. Then replace the '-' with a '+'. declare @i1 int; declare @i2 int; set @i1=1; set @i2= - @i1; select @i2;
  • 0 Votes
    10 Posts
    0 Views
    J
    Nadia Monalisa wrote: I mean, performance and portability wise. On average performance is unlikely to be a concern for a single user system. With specific information about the functional needs of your application it might be more relevant. Reliability on the other hand could be a factor. Portability is probably meaningless because anything that is going to run .Net is going to be able to run SQL Server. Presumably there is no intention at all, under no circumstances, where more than one user of the database is required. If so then SQL Server is probably a better choice. Installation can be made a non-issue by providing an installer that installs everything.
  • Recordset results

    database tutorial
    10
    0 Votes
    10 Posts
    0 Views
    W
    No problem :) The need to optimize rises from a bad design.My articles[^]
  • 0 Votes
    1 Posts
    0 Views
    No one has replied
  • combo box issue

    database performance help question
    2
    0 Votes
    2 Posts
    0 Views
    J
    cb2 = CStr (me.cbo2.text) List of common misconceptions
  • 0 Votes
    2 Posts
    0 Views
    J
    A dataset requires approximately ten times the space of the actual data (give or take a lot). So if you're running a 32 bit application I would not be surprised if you hit the 2 GB program limit. Can you use a datareader instead and page the data? Or store the data more efficiently in a collection instead of a dataset? List of common misconceptions
  • database connectivity

    php database
    3
    0 Votes
    3 Posts
    0 Views
    W
    Your query returns lots of results: http://www.google.com/search?q=php+code+to+read+from+the+database[^] In order to get good answers you should be able to show that you've already tried to solve things out or built something but perhaps encountered a specific problem which you would like solve with the help from people at discussion forums. One good rule of thumb is that typically the answers are as good as the question. I'm really confident that if you pinpoint an exact problem you'll receive quality help from the forums.
  • Syntex Error, Missing Operator !!!

    database help
    8
    0 Votes
    8 Posts
    0 Views
    W
    No problem :) The need to optimize rises from a bad design.My articles[^]
  • How to make auto number start from 2000

    database tutorial
    5
    0 Votes
    5 Posts
    0 Views
    A
    This[^] may help. The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
  • the opposite of 'Safe'

    question help
    15
    0 Votes
    15 Posts
    0 Views
    A
    thank you for doing this, Alen. Help people,so poeple can help you.
  • pivoting more than one column in sql server

    database sql-server sysadmin
    6
    0 Votes
    6 Posts
    0 Views
    M
    Now you are trying to put UI/presentation logic into the database operation. Adding the additional row with the year is not a database operation it needs to be done in your application. Never underestimate the power of human stupidity RAH