Skip to content
Code Project
CODE PROJECT For Those Who Code

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
  • connecting to a database oracle 10g

    csharp database oracle help
    4
    0 Votes
    4 Posts
    1 Views
    A
    User Id=SYSTEM;Password=MANAGER;Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.4)(PORT=1521))(CONNECT_DATA=(SID=XE))) Use you connection string like this. Thanks & Regards, Anil Chelasani
  • GROUP BY Clause...

    database help question
    5
    0 Votes
    5 Posts
    0 Views
    M
    Me didn't look at the details of the answer, just looked at the complexity and shook the head. I don't think Nilandri answered the question which was to group by the date only in a datetime field that has the time component in it. Never underestimate the power of human stupidity RAH
  • Multiple values associated with a single value

    tutorial question database design
    4
    0 Votes
    4 Posts
    0 Views
    A
    I think Rob's idea is better as it is easy to handle, rather than to make All-in-One table. There is really a basic databse rule invloved here that we should make another table for the multi-valued attributes. Parent table's primary key will be foriegn in the newly made table.
  • exported the first column of an excel file to a table

    database com sysadmin
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • Debugging in SQL Server 2005

    database question sharepoint sql-server visual-studio
    2
    0 Votes
    2 Posts
    0 Views
    M
    I got the fix. I don't have the rdbgsetup.exe in 1033 folder, even though 1033 folder is present. Do I need to reinstall this or is it available for free download from net? I tried in google, but didn't get anything such. Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
  • sqlconnection::open()

    database sysadmin help question
    5
    0 Votes
    5 Posts
    0 Views
    S
    I think even using DB name is not a proper solution. What will happen if there is some error in DB Name? (http://www.improve.dk/blog/2008/03/10/controlling-sqlconnection-timeouts[^])This URL gives some good solution for this problem.
  • 0 Votes
    5 Posts
    0 Views
    A
    Did Ashcroft' answer help? You will have to change all references to these field names in all Functions and Stored Procedues that call them in code. I don't speak Idiot - please talk slowly and clearly 'This space for rent' Driven to the arms of Heineken by the wife
  • Require StoredProc

    sharepoint help
    5
    0 Votes
    5 Posts
    0 Views
    N
    Try this CREATE PROCEDURE [dbo].[USP_CheckUserAvailability] -- Add the parameters for the stored procedure here ( @UserName AS VARCHAR(50) ) AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- Insert statements for procedure here IF EXISTS( SELECT [User Name] FROM tbl_User WHERE [User Name] = @UserName ) BEGIN SELECT * FROM tbl_User END ELSE INSERT INTO tbl_User ([User Name]) VALUES (@UserName) END Hope this helps :) Niladri Biswas
  • Database Name

    database question
    8
    0 Votes
    8 Posts
    0 Views
    B
    Thanks
  • Best Practices Q

    discussion
    3
    0 Votes
    3 Posts
    0 Views
    L
    Member 4501940 wrote: that it is a good practice to return the new or updated rec using output parameters. Having multiple paths to Rome doesn't mean that one traderoute is the "bestest". Some paths are optimized for heavy traffic, while others are only accessible by horse. It's a good practice to let the programmer decide what solution would fit best into the problem at hand. It might be quite acceptable to return the identity using a simple select statement :) I are Troll :suss:
  • clarification

    database help question
    7
    0 Votes
    7 Posts
    0 Views
    H
    yes darren, thanks for your info. me to not noticed the same. its working fine when i execute from the procedure from the SQL Query editor. but if i run from the application (asp.net C#) using command.executereader(), i m not getting the result, do you have any ideea?
  • return value,

    database help tutorial question
    4
    0 Votes
    4 Posts
    0 Views
    D
    You may want to take a look at the sp_executesql system stored procedure: http://msdn.microsoft.com/en-us/library/ms188001.aspx[^] This allows you execute the dynamic SQL string, as well as specify parameter definitions and parameter assignments that can bind local SQL variables to the dynamic SQL call. DECLARE @InputParam int, @OutputParam int EXECUTE sp_executesql 'query', N'@DynamicInputParam int, @DynamicOutputParam int OUTPUT', @DynamicInputParam = @InputParam, @DynamicOutputParam = @OutputParam OUTPUT Within 'query', use the dynamic parameters/variables defined in the 2nd parameter (@DynamicInputParam and @DynamicOutputParam). Within 'query', these variables will initially contain the values of (@InputParam and @OutputParam). If a dynamic parameter is defined as an OUTPUT parameter (@DynamicOutputParam), any assignment to that variable will be reflected in the local variable (@OutputParam) after the call to sp_executesql.
  • Looking for field name standards documents

    com business
    2
    0 Votes
    2 Posts
    0 Views
    L
    Ray Cassick wrote: Things that address naming conventions across various industry\business segments so that I can look to normalize a set of tables for a generalized system that could cross industry boundaries and still manage to keep some standardization across industry expectations would be great. Probably not what you expected, but I'd go for English. No systems hungarian, just a short name in a single language. Now, a fieldname is rarely self-descriptive, so it would be a good idea to keep a list with the fieldnames along with their descriptions. That way you can make sure that everybody knows what you mean when you refer to a "client". A good description should be self-explanatory to readers who have no specific knowledge of either domain. That requires a definition of the fields' contents in such a way that it's not going to be confusing to the reader, whether it's a programmer thinking about sockets or an enduser thinking about leads - it should be clear from the documentation of the design what a "client" is. Your goal would be to remove any possible ambiguity. MSDN[^] would be a general pointer. It would also help if you use a standard-unit of measurement, where possible. --edit-- SQL is case-insensitive, hence no recommendations on the use of camelCasing and the like :) I are Troll :suss:
  • MSSQL 7 Decryptor

    database sql-server tutorial question
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • Connection string loaded from config file

    database sysadmin debugging xml question
    3
    0 Votes
    3 Posts
    0 Views
    N
    I would have thought so. I have just written test code to return cnStr, and I find that dataSource is NIGELPC\\\\SQLEXPRESS! Wrote a snippet to remove the extra \\ and now it works.
  • SQL Server 2005 Express edition Registration.

    sysadmin database sql-server question
    6
    0 Votes
    6 Posts
    0 Views
    L
    Usually it's just a matter of installing, enabling remote connections if at all required, and done :) Is your Windows-account allowed to see the other server? Are you on the same domain? I are Troll :suss:
  • 0 Votes
    6 Posts
    0 Views
    C
    Glad you got it. It took me a while to type my last replay as I am at work. :)
  • 0 Votes
    3 Posts
    0 Views
    J
    I tried this code but it's looping forever and adding the first record from the clients into the accounts_summary thougsands of times.. why? USE takhlees SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON SET NOCOUNT ON DELETE FROM accounts_summary -- reset primary key INSERT INTO accounts_summary (account_number, account_name, core_account, is_read_only) VALUES (10000000001, 'CASH', 'True', 'True') INSERT INTO accounts_summary (account_number, account_name, core_account, is_read_only) VALUES (10000000002, 'ACCOUNTS RECEIVABLE', 'True', 'True') DECLARE @client_id int, @client_cpr varchar(50), @client_name varchar(255), @account_number_string VARCHAR(50), @account_number numeric(38,0) DECLARE account_numbers CURSOR FOR SELECT clients.client_id, clients.client_cpr, clients.client_name FROM clients ORDER BY clients.client_name OPEN account_numbers FETCH NEXT FROM account_numbers INTO @client_id, @client_cpr, @client_name WHILE @@FETCH_STATUS = 0 BEGIN INSERT INTO accounts_summary (client_category, client_id, cr_cpr_number, account_number, account_name) VALUES ('I', @client_id, @client_cpr, SCOPE_IDENTITY(), @client_name) -- get random from 1 to 7 SET @account_number_string = RIGHT('0' + convert(varchar(1), DATEPART(WEEKDAY, GETDATE())), 1) -- get random from 1 to 365 SET @account_number_string = @account_number_string + RIGHT('000' + convert(varchar(3), DATEPART(DAYOFYEAR, GETDATE())), 3) SET @account_number_string = @account_number_string + RIGHT('0000000' + convert(varchar(7), SCOPE_IDENTITY()), 7) SET @account_number = convert(bigint, @account_number_string) UPDATE accounts_summary SET account_number = @account_number WHERE account_id = SCOPE_IDENTITY() UPDATE clients SET account_number = @account_number WHERE client_id = @client_id FETCH NEXT FROM account\_numbers INTO @client\_id, @client\_cpr, @client\_name END CLOSE account_numbers DEALLOCATE account_numbers
  • Interesting question about a MIN function and usage

    question database
    8
    0 Votes
    8 Posts
    0 Views
    C
    Sorry for the confusion. I did notice that I did a cut & paste instead of a copy & paste so I edited my query. There should be two queries select @minval = min(stockval) from table where stockdate between d1 and d2; select @mindate = stockdate from table where stockdate between d1 and d2 and stockval = @minval; Not being a C programmer I do not normally use the semicolon which in T-SQL is not needed. Hope this helps.
  • 0 Votes
    2 Posts
    0 Views
    C
    In short, Is UPDATE-WHERE-EXISTS able to handle concurrency? If not, then is there any way to get that done?