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
  • Array Issue

    help database data-structures tutorial question
    6
    0 Votes
    6 Posts
    28 Views
    J
    Your pretty far off with your code, and I'm not sure which version of PHP your using. Plus your code is very primitive and not object oriented like for PHP versions 7 and up. You have to create a db connector as a class and call that db connector. Then create a query. Next run that query with the db connector which creates a result. The result can be false if nothing comes back, or can be a array of records in which you fetch them. Finally you call that array that was returned and convert them to rows. I packed the rows into an object that I created, and return the object instead of an array. The code your writing is very the year 2000, and is quite old and outdated. Nobody in western democracies are writing code like that anymore. PHP 7.4 example, what you should be learning. Hope that helps you, and PHP Storm by Jet Brains is the preferred editor or IDE for PHP. public static function getUsers(): Users { $users = new Users(); $query = " SELECT uid, Username FROM \[user\] WHERE User\_type <> 'xxxxxxx' ORDER BY Username"; $conn = DbConnectRepository::createConn(); $result = sqlsrv\_query($conn, $query) or die(" getUsers " . \_\_LINE\_\_ . " - " . $query . ' - ' . print\_r(sqlsrv\_errors())); while ($row = sqlsrv\_fetch\_array($result)) { $user = new User(); $user->setUserId($row\[0\]); $user->setUserName($row\[1\]); $users->add($user); } return $users; } If it ain't broke don't fix it Discover my world at jkirkerx.com
  • 0 Votes
    3 Posts
    20 Views
    CHill60C
    The previous response was about MS SQL stored procedures - this one is about MySQL stored procedures https://www.sqlshack.com/learn-mysql-the-basics-of-mysql-stored-procedures/[^] The differences are minimal but there are differences. The principal of my response is the same as the previous one however, please do your own research
  • SQL Practice, puzzles and more

    database beta-testing tutorial code-review learning
    1
    0 Votes
    1 Posts
    10 Views
    No one has replied
  • 0 Votes
    1 Posts
    5 Views
    No one has replied
  • remove

    2
    0 Votes
    2 Posts
    15 Views
    OriginalGriffO
    Please don't repost if your question does not appear immediately: all of these went to moderation and required a human being to review them for publication. In order to prevent you being kicked off as a spammer, both had to be accepted, and then I have to clean up the spares. Have a little patience, please! I've deleted the spare. "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
  • Sql Match

    database design regex
    1
    0 Votes
    1 Posts
    8 Views
    No one has replied
  • [Resolved] Need Help with this SQL Statement

    database help
    6
    0 Votes
    6 Posts
    35 Views
    C
    The problem was in the OrderPymts table. I used the PaymentId to resolve the issue. Now it displays the right number of items in the Invoice.
  • Import CSV Problems

    help csharp html database sql-server
    14
    0 Votes
    14 Posts
    61 Views
    J
    Excel doesn't handle text qualifiers as far as I can see. And handling stringsplits and such in Excel would indeed quickly become draconian. Access I don't even want to try. ;P Wrong is evil and must be defeated. - Jeff Ello
  • Diagram Database.

    database xml question
    7
    0 Votes
    7 Posts
    37 Views
    L
    A database diagram is the very foundation of a database design and development effort. It represents the basic structure of a database; how information is stored, categorized and managed within it. Creately supports all database models (i.e. relational model, hierarchical model, network model etc.), and the following database model templates are made with its Database design software Source:[ Database Model Templates ](https://creately.com/blog/examples/database-model-templates/)
  • Database programming

    c++ database oop tutorial question
    2
    0 Votes
    2 Posts
    21 Views
    L
    You already posted this question in QA at How do I build a console application in C++ which uses database to store data?[^]. Please do not crosspost.
  • 0 Votes
    2 Posts
    14 Views
    Richard DeemingR
    You have already posted this in QA: How to design mssql db for storing name/value objects of unknown value type (EF core 5 as ORM)?[^] "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
  • 0 Votes
    3 Posts
    19 Views
    J
    Hopeless Idealist wrote: I would rather type:...but all the companies demand SQL-devs. First of course because companies do not operate to please you. They operate to make money. And that comes from pleasing customers. Both in sales and in follow up support. Additionally they must keep costs low. At the end of the day technologies do not drive company success. Rather it is matter of successfully creating a product(s)/service(s) which the company can maintain and enhance. And of course then selling it in the first place. Large companies almost always have multiple persisted datastores. And I only say 'almost' because I can't be sure that there is not one company out there that only uses one. I do know that Microsoft, Oracle, Netflix, Google and Amazon all use different ones.
  • Get columns name

    database question
    17
    0 Votes
    17 Posts
    88 Views
    Richard DeemingR
    I suggest you read the documentation: sys.columns (Transact-SQL) - SQL Server | Microsoft Docs[^]: Column IDs might not be sequential. If a column has ever been dropped from the table, you will end up with gaps in the column ID sequence. To get a true ordinal position, you'd need to use the ROW_NUMBER windowing function - for example: SELECT [name], ROW_NUMBER() OVER (ORDER BY [column_id]) As [Ordinal] FROM sys.columns WHERE [object_id] = OBJECT_ID('MyTable') ORDER BY [column_id] "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
  • 0 Votes
    1 Posts
    10 Views
    No one has replied
  • 0 Votes
    5 Posts
    27 Views
    R
    There's no table named "S_ware" ... so the FROM clause will issue (most likely) "Invalid object name". I've also noticed that, in the second post to this thread, you've given a bit more information ... but you're declaring a variable as VARCHAR; the SET is ok. But suddenly 'listOfProducts' has become a temporary TABLE. So there are naming issues also. This all sounds like pedantry from me so I'll quit. Suffice to say I'd look up TABLE, SET, DECLARE, and the advanced XML in the BOL for SQL Server version you think you have.
  • Looking for advice on key/value storage options

    csharp css postgresql mongodb dotnet
    7
    0 Votes
    7 Posts
    37 Views
    C
    Imagine you load a file that has 3 sets of timeseries data: attributeA, attributeB and attributeC. Each timseries is of the form Array. There will be between 1000 and 15,000 time/value pairs in each series, so maybe 8Kb to 120Kb in each series. I will never query the data in the array. I will only ever return it as a chunk of data (meaning I could compress it into a BLOB for higher storage efficiency at a tradeoff in load speed if I needed to) A classic database such as MySQL or SQL Server seems massive overkill for this. cheers Chris Maunder
  • Select with pivot

    database sql-server sysadmin help question
    6
    0 Votes
    6 Posts
    34 Views
    CHill60C
    Sorry, I still do not understand what you are saying. Please post the code here to illustrate your point. There are no errors reported in my code - or do you think you are replying to the Original Poster?
  • Open Office Database

    database workspace
    3
    0 Votes
    3 Posts
    25 Views
    B
    Well Richard, No, Not so far, Thanks for the link. Going there next. Bram van Kampen
  • what is query

    database android com question
    1
    0 Votes
    1 Posts
    5 Views
    No one has replied
  • Data Types in SQL

    database com question
    1
    0 Votes
    1 Posts
    9 Views
    No one has replied