|
Hi Mycroft,
Is it possible to use tutorNRIC as my primary key instead of tutorID ? my tutorID is just an index for me to keep track how many people have signed up.
Another question is that how should I do my insert statement based on many to many relationship ?
|
|
|
|
|
karengsh wrote: Is it possible to use tutorNRIC as my primary key Yes it is possible just wrong. A user should NEVER be able to edit a primary key.
karengsh wrote: my tutorID is just an index for me to keep track how many people have signed up. That statement means you need to do some reading/learning on database design. A primary key should be stupid and used for just one purpose, to identify the record, NOTHING else.
Normally you would create the primary records and when you link them (via the UI) you create the link record with the 2 primary keys.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi Mycroft,
The thing is that in my country NRIC is unique. Nobody holds the same NRIC.
In this case, can I make it my Primary key ? And I'd like tutorID as my index with incremental value?
|
|
|
|
|
You are missing the point - NRIC is EDITABLE by the user therefore it should not be used as a primary key - you can put a unique constraint on it but do not use it as a foreign key in a related table.
karengsh wrote: And I'd like tutorID as my index with incremental value That is fine but it will not be a count of the records in the table.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
ok. Tks. Mycroft Holmes.
However, how do I insert into the third table?
Should I use select subj_Id from subject and select tutor_id and then insert into the 3rd table ?
|
|
|
|
|
|
Your question is not very clear.
Are you asking why we use datareader.
The following link might be a good read for you
DataSet vs. DataReader[^]
|
|
|
|
|
I think he just wanted to say hello...
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
I am trying to run an SSIS Package which is using Oracle Db as Datasource. When I am running the Package I am getting the above error: attempt to load oracle client libraries threw badimageformatexception ssis. I have downloaded the Oracle Client tools as suggested in a link upon goolging. Still I am not able to find an answer for it. Any help can be greatly helpful.
As that Database is secured, I am encrypting the connection string and placing it into a variable, then assigning to ConnectionString property the Source Connection, could it be the problem? I am not understanding what am I missing here.
Any help would b very helpful thanks in advance.
Thanks in advance.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
-- modified 1-Jun-17 20:13pm.
|
|
|
|
|
A "bad image format" exception usually points to trying to load 64-bit libraries in a 32-bit AppDomain, or vice-versa.
You'll need to check whether your package is running as 32-bit or 64-bit, and make sure you're loading the correct version of the Oracle libraries.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I'm using ADO.NET.
Entity Framework is not an option.
Suppose I have an IDataReader instance that was created from calling a stored procedure that returns 150,000 rows.
If I create a DataTable , and then call DataTable.Load(IDataReader) , does it:
1. Read all available rows into the table at once?
2. Read only those rows that are necessary to return whatever rows I read from the DataTable ?
3. Some hybrid of the above two scenarios?
I'm interested in implementing a solution that only reads data from the server upon demand.
IOW, I don't want my form to only appear on screen after all 150,000 rows have been pulled from SQL Server.
Thank you very much for your insight.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
#1 - it loads all of the rows into memory at once. DataTable.Load | Reference Source[^]
Displaying 150,000 rows on screen in one hit is not a good idea. How is the poor user ever going to find the one row they're interested in? There must be some way to summarise, filter, or page the data to make it easier to consume.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks for your response. I only chose 150,000 as a theoretical number to make my point.
There would never be that many rows, but in our main LOB application, some developers in the past have loaded up around 10,000 rows, making the form rather slow to open!
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I agree with Richard, 150k records to the UI is only valid if you are doing a data dump and there are more efficient way to do that.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Yes, I agree with you and Richard. I'm working on creating a generic way to load the data only on demand. It must be a business object agnostic way.
Thanks.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
If you are using SQL Server I think there is a method of loading a "page" of data which my be valid. Obviously I have never used it, I limit UI lists to a max of 2k. After that filters become mandatory.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
We have one form that displays Purchase Orders, and the data goes back to 2009. There are thousands upon thousands of records.
How can you limit how many rows you load, and yet still allow the user to type in a column filter string in order to find any of the PO's from any point in time?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Richard Andrew x64 wrote: IOW, I don't want my form to only appear on screen after all 150,000 rows have been pulled from SQL Server. Then how?
You mentioned a "form", so I'd assume WinForms with a DataGridView. In which case you don't use a datatable, but a list. You add to the list from a different thread, in batches of 50. Virtualize the DataGridView. Start the actions as soon as the form is displayed.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote: You add to the list from a different thread, in batches of 50
Thank you. That's one of the avenues I am exploring. I have to find some way to make our application more responsive while still enabling access to thousands of rows.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
|
|
Thank you, this looks very promising.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
SQL server 2014/2016, SMO.
Using SMO to backup a databse to 'D:\SQLBK\Mon\dbc.bak' on server:
public int BackupDB(string serverName, string dbName, string backupFolder)
{
Server oServer = new Server(new ServerConnection(ServerName));
Backup oBackup = new Backup();
oBackup.Action = BackupActionType.Database;
oBackup.Database = dbName;
oBackup.Initialize = false;
oBackup.Incremental = false;
oBackup.LogTruncation = BackupTruncateLogType.Truncate;
string sBackupFilename = Path.Combine(backupFolder, dbName + ".bak");
oBackup.Devices.AddDevice(sBackupFilename, DeviceType.File);
oBackup.SqlBackup(oServer);
return 0;
}
How to get original database information from backup file 'D:\SQLBK\Mon\dbc.bak' through SMO? e.g. database name.
|
|
|
|
|
w14243 wrote: How to get original database information from backup file 'D:\SQLBK\Mon\dbc.bak' through SMO? e.g. database name. The database-name is not part of the backup. You backup the data, not meta-data on the file.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
SQL Server 2014/2016, using SMO.
Want backup database 'dbName' of server 'serverName' to server folder 'backupFolder'.
1.Backup remote database, not backup local database.
2.The 'backupFolder' is on remote server, e.g. "D:\SQLBK\Mon".
public int BackupDB(string serverName, string dbName, string backupFolder)
{
Server oServer = new Server(new ServerConnection(ServerName));
Backup oBackup = new Backup();
oBackup.Action = BackupActionType.Database;
oBackup.Database = dbName;
oBackup.Initialize = false;
oBackup.Incremental = false;
oBackup.LogTruncation = BackupTruncateLogType.Truncate;
string sBackupFilename = Path.Combine(backupFolder, dbName + ".bak");
oBackup.Devices.AddDevice(sBackupFilename, DeviceType.File);
oBackup.SqlBackup(oServer);
return 0;
}
The 'backupFolder' is folder on 'serverName', not local folder.
1.If 'backupFolder' is not exist on 'serverName', the 'SqlBackup' command will cause exception on 'folder not exist'.
2.If use 'Directory.CreateDirectory(backupFolder)', then local folder will be created, not remote folder.
So I want:
1. The 'SqlBackup' command can auto create specified backup folder. How to do it?
2. If above can't be done, then how to create 'backupFolder' on 'serverName' by SMO or other method?
|
|
|
|