 |
 |
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
Do you know if it exist a document or recommendation to create audit table or metadata elements on a database.
I ask this question because I just saw this :
CREATE TABLE client (
id char(36) NOT NULL,
first_name varchar(255) NOT NULL,
last_name varchar(255) NOT NULL,
creation_date timestamp NOT NULL,
update_date timestamp NOT NULL,
CONSTRAINT client_pk PRIMARY KEY (id)
);
I don't like the idea to have metadata like creation_date and update_date in a business oriented table. Actually these two fields exists in all tables of this database.
What if I create a audit table like this:
CREATE TABLE audit (
table_name char(32) NOT NULL,
fk char(36) NOT NULL,
update_date timestamp NOT NULL
);
I don't need a creation date because the creation date is my first record with table_name and fk in this table. I could add a columns to add insert, update, delete information. With thi table I keep all my update dates and not only the last one.
Is this audit table a god practice ?
Can I also use this audit table to avoid conflict. You know when two users update the same record at the same time. It's possible to use the last update time to warn them there is a conflict.
|
|
|
|
 |
B413 wrote: I don't like the idea to have metadata like creation_date and update_date in a business oriented table. It's just a good idea to do so. Makes sorting by creation-order easier, makes it easy to see when the table last was updated - but it's not an audit. It doesn't show who changed what, it merely shows when the object was created, and when it was last modified. You'll find those two attributes on a lot of things.
Fetching the top(update_date) gives a fast indication whether the table has changed since you last loaded it into memory.
B413 wrote: Is this audit table a good practice ? Depends; who's responsible for entering data into the new table? Does it happen automatically (using a trigger), or do you depend on the cooperation of the DAL-programmer?
I'd simply be dumping a copy of the entire record (in a separate table, different access-rights), including the user-name and domain. It'd be wasting less space if you only keep a track of the fields that are actually modified then when one makes a complete copy. OTOH, space is cheap nowadays
B413 wrote: Can I also use this audit table to avoid conflict. You know when two users
update the same record at the same time. It's possible to use the last update
time to warn them there is a conflict.
..and then what? Ask the user to undo the work he's done and type it again? Merge the changes? What if they modified the same field?
It's a bit sweeter to "check out" (or lock) the record once a user starts editing. What sourcesafe does with files works equally well with records.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
 |
I need to setup SQL Server Express using the command line and also make the installation unattended I tried many command lines however each one of them did not work here is the last one:
Setup.exe /ADDCURRENTUSERASSQLADMIN="True" /AGTSVCACCOUNT="NT AUTHORITY\NETWORK SERVIC" /AGTSVCSTARTUPTYPE="Disabled" /ASBACKUPDIR="Backup" /ASCOLLATION="Latin1_General_CI_AS" /ASCONFIGDIR="Config" /ASDATADIR="Data" /ASLOGDIR="Log" /ASPROVIDERMSOLAP="1" /ASSVCSTARTUPTYPE="Automatic" /ASTEMPDIR="Temp" /BROWSERSVCSTARTUPTYPE="Disabled" /ENABLERANU="True" /ENU="True" /ERRORREPORTING="False" /FARMADMINPORT="0" /FEATURES="SQLENGINE,REPLICATION" /FILESTREAMLEVEL="0" /HELP="False" /INDICATEPROGRESS="False" /INSTALLSHAREDDIR="C:\Program Files\Microsoft SQL Server\" /INSTALLSHAREDWOWDIR="C:\Program Files (x86)\Microsoft SQL Server\" /INSTANCEDIR="C:\Program Files\Microsoft SQL Server\" /INSTANCEID="SQLExpress" /INSTANCENAME="SQLExpress" /ISSVCACCOUNT="NT AUTHORITY\NetworkService" /ISSVCSTARTUPTYPE="Automatic" /NPENABLED="0" /QUIET="True" /QUIETSIMPLE="False" /ROLE="AllFeatures_WithDefaults" /RSINSTALLMODE="FilesOnlyMode" /RSSVCACCOUNT="NT AUTHORITY\NETWORK SERVICE" /RSSVCSTARTUPTYPE="Automatic" /SECURITYMODE="SQL" /SQLCOLLATION="Arabic_CI_AS" /SQLSVCACCOUNT="NT AUTHORITY\NETWORK SERVICE" /SQLSVCSTARTUPTYPE="Automatic" /SQMREPORTING="False" /TCPENABLED="0" /UIMODE="" /X86="False" /IACCEPTSQLSERVERLICENSETERMS /ACTION="Install"
But also it did not work. Could any one tell the correct syntax to install the SQL Server Express 2008 x64
|
|
|
|
 |
Amr Muhammed wrote: But also it did not work That's a great statement. What was the result? Did you get any error messages? What does the log file of the installer tell you?
|
|
|
|
 |
Hi
i have issue in stored procedure converting data type
Destination table dbo.Z_tbl_CirculationCopy_TEMP has numeric data type
But source table Z_tbl_Import_temp have VarChar Type
If I export data from source, I have error message
Msg 8114, Level 16, State 5, Procedure Z_usp_IMPORT_EXCEL_UNPIVOT_1, Line 10
Error converting data type varchar to numeric.
Pls help to resolve this issue
Thanking you in advance
Maideen
Below is my store procedure
INSERT INTO dbo.Z_tbl_CirculationCopy_TEMP([MEMBER],[LANGUAGE],[TYPE],[PLATFORM],[CATEGORY],[MAINAREA],[STATE],[COPIES],
[MONTHNAME],[YEARNO],[REMARKS],[AVGISSUE_PAID],[AVGISSUE_FREE],[BCP_NTT],[BCP_50],[BCP_20],[BCP_20_Below],
[WP_TOTAL],[SABAH_TOTAL],[SARAWAK_TOTAL],[EM_Total])
SELECT [MEMBER],[LANGUAGE],[TYPE],[PLATFORM],[CATEGORY],[MAINAREA],[STATE],[COPIES],
[MONTHNAME],[YEARNO],[REMARKS],[AVGISSUE_PAID],[AVGISSUE_FREE],[BCP_NTT],[BCP_50],[BCP_20],[BCP_20_Below],
[WP_TOTAL],[SABAH_TOTAL],[SARAWAK_TOTAL],[EM_Total]
FROM (SELECT [MEMBER],[LANGUAGE],[TYPE],[PLATFORM],[CATEGORY],[MAINAREA],[MONTHNAME],[YEARNO],[REMARKS],
[AVGISSUE_PAID],[AVGISSUE_FREE],[BCP_NTT],[BCP_50],[BCP_20], [BCP_20_Below],
[WP_TOTAL],[SABAH_Total],[SARAWAK_Total],[EM_Total],
[Perlis],[Kedah],[Penang],[Perak],[Kelantan],[Terengganu],[Pahang],[Selangor],[WP],[NegriSembilan],[Melaka],[Johor],
[KotaKinaBalu],[sandakan],[Tawau],[Kudat],[Pendalaman],[Labuan],[SABAH_Other],
[Kuching],[Miri],[Sibu],[Bintulu],[SriAman],[KotaSemerahan],[Sarikei],[SARAWAK_Others],[Others]
FROM dbo.Z_tbl_Import_temp ) P
UNPIVOT (Copies FOR State IN ([Perlis],[Kedah],[Penang],[Perak],[Kelantan],[Terengganu],[Pahang],[Selangor],
[WP],[NegriSembilan],[Melaka],[Johor],
[KotaKinaBalu],[Sandakan],[Tawau],[Kudat],[Pendalaman],[Labuan],[SABAH_Other],
[Kuching],[Miri],[Sibu],[Bintulu],[SriAman],[KotaSemerahan],[Sarikei],[SARAWAK_Others],[Others]
))AS unpvt
|
|
|
|
 |
Your excel sheet is probably formatted with comma.
You should split out your unpivot and inspect the results of the query to try and determine the invalid data, look for blanks, character and formatting (commans)
Never underestimate the power of human stupidity
RAH
|
|
|
|
 |
I have a named instance of 2008 r2 located on my windows 7 professional local machine. I have tried to get my connect string to work but I just cant. I am using machine name "HOLDORF-PC" SQL instance name "SQL_2008_R2" and the rest of the connection string. Here is my connection string:
"Data Source=HOLDORF-PC\\SQL_2008_R2;Initial Catalog=EFDataModel" providerName="System.Data.SqlClient" />
Please help
Steve Holdorf
|
|
|
|
 |
The CS does not say whether you want to use mixed mode or windows authentication. There's examples here[^].
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
 |
I tried this:
"Data Source=HOLDORF-PC\\SQL_2008_R2;Initial Catalog=EFDataModel; Integrated Security=SSPI" providerName="System.Data.SqlClient"
and it still does not work?
|
|
|
|
 |
Sorry, I tried this:
"Data Source=HOLDORF-PC\\SQL_2008_R2;Initial Catalog=EFDataModel; Integrated Security=True"
and it still doesn't work. One point is that this is the connection string that coexists with my Entity Framework model.
|
|
|
|
 |
OK. I think you were right on the DB connection string. Now, I'm getting this error: An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct. Here is my Entity Framework connection string:
<add name="EFDataModelEntities2" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=HOLDORF-PC\SQL_2008_R2;initial catalog=EFDataModel;integrated security=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" /> And here is my Model connections: <EntityContainer Name="EFDataModelEntities2" annotation:LazyLoadingEnabled="true"> <EntityContainerMapping StorageEntityContainer="EFDataModelModelStoreContainer" CdmEntityContainer="EFDataModelEntities2">
|
|
|
|
 |
I don't use EF; I've no idea what it epects beyond a normal SQL-server connection string. According to MSDN[^] your string looks correct.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
 |
lholdorf wrote: Check the inner exceptions for details and ensure that the connection string is correct.
This is a good time to post the inner exceptions.
|
|
|
|
 |
Where does your asp.net application run - on the same machine? If not, configure the SQL Server to accept connections from other machines.
And what about the account the IIS is running with? Does that account have sufficient access rights to the database? I suggest SQL Server authentication instead of WIndows authentication - do not forget to configure your SQL Server to allow that.
|
|
|
|
 |
lholdorf wrote: HOLDORF-PC\\SQL_2008_R2
Is the double back-slash between the machine name and the instance name a typo in your question, or a mistake in copying the connection string from a C# source file to the web.config file?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
 |
Hello- can you give me any example scenarios/questions for writing a complex SELECT statements? My intention is to improve my SQL skills.
|
|
|
|
|
|
 |
Sure, try implementing a Turing Machine in SQL.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
 |
data modeling guy wrote:
Hello- can you give me any example
scenarios/questions for writing a complex SELECT statements? My intention is to
improve my SQL skills.
- Calculate reputation points of a user.
- Fetch the contibutions-section for a user (see the section on your user-page; it contains some statistics)
- Fetch the ten members from the database that answered most questions last month.
- Fetch the voting-percentages for the straw-poll result for all possible answers.
- Fetch any low-repuation member that posts the same message in multiple places, ordered by the amount of similar messages.
- Fetch the data to show the forum-content for page 3 of this forum, in threaded view, with 50 posts per page.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
 |
No no no these suggestions expect him to do the work and write the queries, it sounds like he wants YOU to write the queries and he will study them.
Good luck getting CM to lend out the database and schema
Never underestimate the power of human stupidity
RAH
|
|
|
|
 |
Thanks Eddy. I Did some more google search and found some more. Cheers!
|
|
|
|
|
 |
I tried this
select convert(datetime, 41818) as mydate
result
2014-06-30 00:00:00.000
In Excel, it should be
6/28/2014
It's always 2 days in advance
Please help!
Thanks a lot
|
|
|
|
 |
Why do you think it's wrong?
SELECT DATEDIFF ( dd , '1900-01-01' , '2014-06-30' )
SELECT DATEADD ( dd, 41818 , '1900-01-01' )
Miller Nguyen wrote: In Excel, it should be
What do you mean "it should be" ?
You'll never get very far if all you do is follow instructions.
|
|
|
|
 |
I don't say it's wrong, that's why I put the QUESTION MARK in the topic.
I just wonder why Excel and SQL are giving different result
|
|
|
|
 |
What the f...? You are right, I tested it.
Look at day number 0: with SQL Server, it is Jan 1, 1900; with Excel: Jan 0 , 1900.
The next bug is the leap year: Excel treats 1900 as a leap year (that's wrong!), while SQL Server correctly knows that 1900 is not a leap year.
In sum, those differences account for the 2 days difference in current dates.
|
|
|
|
|
 |
Yeah, as I drifted off to sleep last night I recalled that Joel had written about Excel having to support a Lotus 123 issue.
You'll never get very far if all you do is follow instructions.
|
|
|
|
 |
I love that story.
They brought a f*** counter to all meetings with BillG.
|
|
|
|
 |
See my answer to Bernhard
|
|
|
|
|
 |
Oh, btw, have a look if this[^] and this[^] would be of any use for you.
|
|
|
|
 |
For example, -0.5 and 0.5 both mean noon on 30 December 1899 No, no, no! I do not want to use that function!
|
|
|
|
 |
It's not a bug, it's a feature.
|
|
|
|
 |
I get around this, and other issues such as collation issues between SQL Server and Excel, by always passing dates to Excel as text in a format of dd-MMM-yyyy e.g. '01-Jan-2014'.
It's not pretty but it has worked so far...
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
modified 30-Jun-14 8:06am.
|
|
|
|
 |
Hi all;
I am learning to write stored procs on MySQL and am going crazy.
DELIMITER $$
DROP PROCEDURE IF EXISTS CleanCopyEnvData$$
CREATE PROCEDURE CleanCopyEnvData ()
BEGIN
insert into EnvData(UserDate, XAction, Balance, UserID)
select
CAST(udate as Date)
, CAST(amount1 as Decimal(6,3))
, CAST(amount2 as Decimal(6,3))
, CAST(UID as UnSigned)
from
DataLoad;
END $$
DELIMITER ;
I get an error:
Error starting at line : 17 in command -
END $$
Error at Command Line : 17 Column : 1
Error report -
SQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'END $$' at line 1
I am using Oracle SQL Developer and the INSERT statement works ok when executed on its own. I can do these things blindfolded with my arms tied on MSSQL. Any help appreciated.
EG.
|
|
|
|
 |
You don't need the delimiter expression $$ after your END statement.
DELIMITER $$
DROP PROCEDURE IF EXISTS CleanCopyEnvData$$
CREATE PROCEDURE CleanCopyEnvData ()
BEGIN
insert into EnvData(UserDate, XAction, Balance, UserID)
select
CAST(udate as Date)
, CAST(amount1 as Decimal(6,3))
, CAST(amount2 as Decimal(6,3))
, CAST(UID as UnSigned)
from
DataLoad;
END
Everyone dies - but not everyone lives
|
|
|
|
|
 |
Glad to help.
Everyone dies - but not everyone lives
|
|
|
|
 |
Hi,
I have .NET WinForm application with MySQL backend.
It's an HR application.
I want to store employee documents such as ID card, passport, letters (e.g. salary certificates, warning letters, etc).
I don't want to store the scanned documents in the database itself therefore I am planning to store it on my file server and just save a link in MySQL.
My question, if I save a link, how can I make sure no one will know that link's folder then open it and see everything else?
Technology News @ www.JassimRahma.com
|
|
|
|
 |
Just store the filenames without the path to the file server in the database table. Store the path to the file server separately say in another database table and concatenate it with the filename by code whenever user wants to access a file.
|
|
|
|
 |
Instead of using a plain database back-end, create a server which communicates with the clients and the database. So any client will contact the server which in turn talks to the database and file system, and serves the data/documents back to the clients.
|
|
|
|
 |
what is difference and similarities between mysql and ms sql server.
|
|
|
|
 |
They are exactly the same except SQL Server is better in every way.
You'll never get very far if all you do is follow instructions.
|
|
|
|
 |
can we use them by replacing each other with other tools for example can i use mysql with asp.net and php with ms sql server
|
|
|
|
 |
|