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
  • Hadoop + esProc Help You Replace IOE

    question css database oracle com
    2
    0 Votes
    2 Posts
    0 Views
    L
    Marked as spam. Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
  • 0 Votes
    2 Posts
    0 Views
    L
    Member 2458467 wrote: in the form of DBO.* Is your user a sysadmin? MSDN[^]: For example, if user Andrew is a member of the sysadmin fixed server role and creates a table T1, T1 belongs to dbo and is qualified as dbo.T1, not as Andrew.T1. Conversely, if Andrew is not a member of the sysadmin fixed server role but is a member only of the db_owner fixed database role and creates a table T1, T1 belongs to Andrew and is qualified as Andrew.T1. The table belongs to Andrew because he did not qualify the table as dbo.T1. Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
  • MariaDB and c#

    csharp mysql database business beta-testing
    4
    0 Votes
    4 Posts
    0 Views
    S
    I downloaded and installed the file that Simon provided at this link[^] (select the one called ADO.NET Driver for MySQL (Connector/NET). When you follow the download links the sly folks at Oracle/MySql try to make logging in to their website "mandatory" and it's easy to miss the tiny "No thanks, just start my download" link below it, so there's no need to register. When you've downloaded and installed it create a project and add an assembly reference to "C:\Program Files (x86)\MySQL\MySQL Connector Net 6.7.4\Assemblies\v4.0\MySql.Data.dll" (obviously, select your Program Files location and the framework version as appropriate). If you have MariaDB installed chances are you have the IDE tool, HeidiSQL installed. I used that to create a new session, database and a table. In HeidiSQL, the menu Tools -> User manager is where I created a user registration and pointed it to "home", 127.0.0.1 and I set the access rights to full, the usual suspects. Here's a code fragment I slapped into a console app (apologies if it doesn't format nicely): string connStr = "server=127.0.0.1;uid=DogzBolx;pwd=password;database=imagecatalog;"; MySqlConnection conn = new MySqlConnection(connStr); conn.Open(); string sql = "select \* from data order by count desc;"; MySqlDataAdapter da = new MySqlDataAdapter(sql, conn); DataTable data = new DataTable(); da.Fill(data); foreach(DataRow row in data.Rows) { string md5 = Convert.ToString(row\[0\]); int count = Convert.ToInt32(row\[1\]); Console.WriteLine(md5 + " " + count); } conn.Close(); Excuse my glib database name. :) I ran the app and (bless my cotton socks) it worked! Anyway, it works fine, and it's rather jolly quick. Whether MariaDB can do what I'm familiar with using SQL Server I can't say but it seems to offer a lot of things. HeidiSQL itself is rather nice. I don't know if there are other tools to maintain MariaDB databases but seeing it's all part of the MariaDB-related family it's certainly works just fine. That's my $0.02c worth. :-D If there is one thing more dangerous than getting between a bear and her cubs it's getting between my wife and her chocolate.
  • Concat NULL yields NULL inside a Function

    database question
    5
    0 Votes
    5 Posts
    0 Views
    F
    Yeah, we should start think about it here, thank you. The problem is that we're using that on the return of a XML. The error are on the XML return. to solve, before call the function we got to use this. SET CONCAT_NULL_YIELDS_NULL ON; GO This is our function CREATE FUNCTION Function_StripHTML(@Text NVARCHAR(MAX), @BreakLine BIT) RETURNS VARCHAR(MAX) AS BEGIN DECLARE @XML AS XML IF @BreakLine = 1 BEGIN SET @Text= REPLACE(REPLACE(REPLACE(@Text,' ', CHAR(13)), ' ',CHAR(13)), ' ',CHAR(13)) END ELSE BEGIN SET @Text= REPLACE(REPLACE(@Text, ' ',' '), ' ',' ') END SET @XML = CAST(('' + REPLACE(REPLACE(dbo.Function\_RemoveInvalidCharacters(@Text), '&', '&'), '<', '')+'') AS XML) SELECT @Text= ( SELECT CASE WHEN LEFT(N.value('.', 'VARCHAR(MAX)'), 3) = 'br>' THEN '<' + N.value('.', 'VARCHAR(MAX)') ELSE STUFF ( N.value('.', 'VARCHAR(MAX)') , 1 , CHARINDEX('>', N.value('.', 'VARCHAR(MAX)')) , '' ) END FROM @XML.nodes('x') AS T(N) FOR XML PATH('') , TYPE ).value('.', 'VARCHAR(MAX)') RETURN LTRIM(RTRIM(@Text)) END GO I'm sorry if the code looks confuse, was made for a coworker here. :-O
  • OLAP database missing...

    question database
    3
    0 Votes
    3 Posts
    0 Views
    G
    There's also a chance that if you are not secured with regards to sql injection attacks - that you have just been the victim of one. Dropping tables is a fairly classic symptom of an sql injection attack. “That which can be asserted without evidence, can be dismissed without evidence.” ― Christopher Hitchens
  • database schema

    database sql-server design sysadmin algorithms
    6
    0 Votes
    6 Posts
    0 Views
    L
    I'm not going to do your homework, but I can point you in the right direction: Normalization and Joins.
  • Conditional query (sql)

    database help
    2
    0 Votes
    2 Posts
    0 Views
    M
    Non tested! Select IsNull(C.CompanyName, P.PersonName) Contact From LinkTable L Left Join ComapanyTable C on C.CompanyID = L.CompanyID Left Join PersonTable P on P.RealPersonID = L.RealPersonID This may help you understand joins Visual Representation of SQL Joins[^] Never underestimate the power of human stupidity RAH
  • Stored Procedures

    question database design help announcement
    10
    0 Votes
    10 Posts
    0 Views
    A
    I Think You Should Add One More Column To Your Main Table As Type Now Your Table Structure Is (Code,Name,ID,Type) Now In Type Column You Can Insert Feeling Or Zone. And Now One One Insert Update And Delete Procedure Can Do The Same, As You Required. ------------------------------------------------------------------- Another Approach You Should Pass Table Name To Your Procedure And Create Dynamic Query. To Execute That Dynamic Query Use SP_ExecuteSQL Hope This Will Help You.......
  • 0 Votes
    7 Posts
    2 Views
    J
    I plugged it in, pretty sure I got the translation right because I don't get a SQL error and the SQL Query matches when I print it out on the screen. It's really close, but I guess it's suppose to produce a result set of 4 rows on almost every dept ID This is out of my league here. oh well. Thanks for help, At least I know my code changes work, and I can do testing with it.
  • 0 Votes
    1 Posts
    2 Views
    No one has replied
  • 0 Votes
    4 Posts
    0 Views
    J
    The "web app" would be the client machine.
  • access procedure

    2
    0 Votes
    2 Posts
    0 Views
    M
    And your QUESTION is! I think Access has a macro function so step through the insert while recording a macro and inspect the SQL code generated. Never underestimate the power of human stupidity RAH
  • Mysql select query with multiple conditions

    database mysql help
    8
    0 Votes
    8 Posts
    0 Views
    M
    thanks for the help:i solved it in another way: query = "select tag_id,category_id,product_id,product_name,gate_id,in_time,out_time,remarks from transaction where DATE(in_time)BETWEEN '" + fromDate + "'AND '" + toDate + "'"; if(R_Tag.Text != "") { query=query+ " AND " + "tag_id=" + "'" + R_Tag.Text + "' "; } if (R_Category.Text != "") { query = query + " AND " + "category_id=" + "'" + R_Category.Text + "' "; //query = "select tag_id,category_id,product_id,product_name,gate_id,in_time,out_time,remarks from transaction where DATE(in_time)BETWEEN '" + fromDate + "'AND '" + toDate + "' AND (tag_id='" + R_Tag.Text + "' OR category_id='" + R_Category.Text + "' OR product_id='" + R_Product.Text + "'OR product_name='" + R_ProName.Text + "' OR gate_id='" + R_Gate.Text + "')"; } if (R_Product.Text != "") { query = query + " AND " + "product_id=" + "'" + R_Product.Text + "' "; } if (R_ProName.Text != "") { query = query + " AND " + "product_name=" + "'" + R_ProName.Text + "' "; } if (R_Gate.Text != "") { query = query + " AND " + "gate_id=" +"'" + R_Gate.Text + "' "; }
  • Sudden cast problem using executescalar

    help database question sysadmin
    3
    0 Votes
    3 Posts
    0 Views
    G
    Thanks, Richard. Saying truth, I've already understand where I made a mistake. I anyway want ExecuteScalar to return db error, so I simply added the test is byte for result before casting: Object sqlResult = ExecuteScalar(sql); if (!(sqlResult is byte)) { return sqlResult.ToString(); } This is the internal module, and WHERE clause is generated programmatically, so I don't see the ability to SQL Injection. Thanks once more. Regards, Gennady My English is permanently under construction. Be patient !!
  • how can left join two table on multiple column???

    question
    2
    0 Votes
    2 Posts
    0 Views
    Richard DeemingR
    If both columns must match: SELECT ... FROM tableA LEFT JOIN tableB ON tableA.ID = tableB.ID AND tableA.CodeGuid = tableB.CodeGuid If either column can match: SELECT ... FROM tableA LEFT JOIN tableB ON tableA.ID = tableB.ID OR tableA.CodeGuid = tableB.CodeGuid "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
  • Does your database desperately need expansion

    performance css asp-net database com
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • SQL connection in Visual studio 2012

    database help csharp c++ sql-server
    5
    0 Votes
    5 Posts
    0 Views
    B
    There are some issues with your connection string. "Database" is the *name* of the database in SQL Server (as you can see it e.g. in SQL Server Management Studio), not the path to the database file. "Integrated Security=true" means that you login with your Windows Credentials. That means, your Windows user must have access rights to the databse. If you want to use a specific (database defined) user, do not use Integrated Security, but set username and password instead. For more information, look at http://www.connectionstrings.com/sql-server/[^].
  • Using SQL LocalDB

    database csharp sql-server visual-studio com
    3
    0 Votes
    3 Posts
    0 Views
    G
    Thanks. I'll give that update a try on another "clean" machine and see if it solves the "invalid key name" error when trying to do an AttachDBFilename. YouTube and My Mu[sic], Films and Windows Programs, etc.
  • CTE Query taking too long

    database question
    7
    0 Votes
    7 Posts
    0 Views
    R
    Thanks Jorgen Unfortunately it not my database to add columns. I tried your query, but it was also slow, however that got me thinking more about the data I am querying. The vektronix table is actually quite large already after only a few months of production (about 8 rows for each unit produced) so I tried limiting the rows from vektronix in the where clause - that worked! ;WITH Dates AS ( SELECT GETDATE()as DateValue UNION ALL SELECT DateValue -1 FROM Dates WHERE DateValue -1 >= dateadd(d,-90,GETDATE()) ) SELECT convert(date,DateValue) as ProdDate , coalesce(trk.Tot,0)as ProdQty FROM Dates D left join (select convert(date,DateCreated) as TrkDate ,SUM(allocated) as Tot from vektronix.[dbo].[Tracking] t where [TrackingTypeId] = '1' and DateCreated >= dateadd(d,-90,GETDATE()) group by convert(date,DateCreated)) as trk on trk.TrkDate = convert(date,DateValue) group by DateValue,trk.Tot order by datevalue desc OPTION (MAXRECURSION 32747) Thanks for your help!
  • How to insert data in the tables

    database tutorial question
    5
    0 Votes
    5 Posts
    0 Views
    R
    in sql you have use from : INSERT INTO table name VALUES ( , , ,