|
Please post connection strings for both database.
Farhan Noor Qureshi
if (this == this) thow this;
|
|
|
|
|
Might have been just an error in your explanation but, your old table name was “datatable” right? This table was deleted after backing up the data right?
Could the problem be you failed to update your open command? It looks like your attempting to open a connection to the old table.
rs->Open("DataTable", _variant_t((IDispatch *)conn,true), adOpenKeyset, adLockOptimistic,adCmdTable);
Anther shot in the dark here, is your autonumber column a 32 bit int? How many rows do you have in that table?
int
Integer (whole number) data from -2^31 (-2,147,483,648) through 2^31 - 1 (2,147,483,647).
ZeePain! wrote: This seems like one of those programs that started small, grew incrementally, building internal pressure, and finally barfed all over its source code sneakers. Or something.
thedailywtf.com[^]
|
|
|
|
|
Thank you for your reply
Let me explain
I have a production live database called FASD. Now I make backup of the database. It will create a back file in harddisk.
Then, I create a brand new database called POMS. On this database, I restore FASD's backup file to it. The steps are
All tasks -> Restore Database -> Restore: From device -> Select device -> Add -> Pick a File name (the database backup file) On the Option tab click Force restore over existing database click box.
It is just like create a copy of production database FASD, and the new name of the database is called POMS. That's it.
Every table in FASD database should be exactly the same in POMS database.
The autonumber column is a 32 bit int. Currently we only have
140000 rows.
One thing I want to mention is that each row contains a binary column. The column stores picture binary data.
The datatype for this column is image. This why the database
is 18GB.
Any idea?
|
|
|
|
|
Do FASD and POMS reside on the same machine? If yes, then, are database files on the same volume (or HDD or partition)?
Farhan Noor Qureshi
if (this == this) thow this;
|
|
|
|
|
Yes FASD and POMS reside on the same machine, same volume (D:\ drive)
Do you know how to look at those database's logic file name?
I notice that when I do the restore, I need changed the physical data file name, and physical log file name to the new physical data and log file name.
For example I need to change D:\MSSQLDATA\MSSQL\Data\FASD.mdf to D:\MSSQLDATA\MSSQL\Data\POMS.mdf and D:\MSSQLDATA\MSSQL\Data\FASD_log.ldf
to D:\MSSQLDATA\MSSQL\Data\POMS_log.ldf
however I am not be able to change to logic file name.
The restore utility read those infomation from the backup file.
|
|
|
|
|
flyflyfly wrote: Do you know how to look at those database's logic file name?
Run select * from sysfiles
IMHO, having same logical file names is not an issue here. Check for the differences (FASD and POMS) in 'Recovery Model', triggers, Locks (Under Management->Current Activity->Locks/Object in EM).
Farhan Noor Qureshi
if (this == this) thow this;
|
|
|
|
|
Hi all,
I have datetime field in database. When I am getting records older than
specific date that I passed in parameter I can not get records that
differs only in Time part of the datetime value.
Looks like comparison of Time portion in query failed.
I am using ACCESS database and ADO OleDbCommand. When in debug in Visual Studio QuickWatch clearly can see that the record that am going to get is older than datetime in TimestampParam by 10 sec (for example). If I substract 1 day from the
database field value I am getting the record. It is definetly time
portion comparison failed.
These are some lines from my code to show how I am reading database
OleDbDataAdapter adapter = new OleDbDataAdapter();
myCommand.CommantText = "SELECT [NetLog].* FROM [NetLog] WHERE
Timestamp < TimestampParam"
adapter.SelectCommand = myCommand;
System.Data.DataSet dataSet = new System.Data.DataSet();
int iNumRows = adapter.Fill( dataSet );
I would appreciate any advice
Thanks,
Roman
|
|
|
|
|
Is possible to keep MSDE on my machine, and install MS SQL EXPRESS 2005?
I want to keep both engines.
|
|
|
|
|
Yes it is possible. I am doing so right now on my machine . Along with MySQL and Firebird.
|
|
|
|
|
The code below should insert this record into the database, I don't the error. I drops through and run the line that enables the btnAdd.Enable = true. How do I fix it?
private void SaveRecord()
{
string strSQL;
if(btnSave.CommandArgument == "Add")
{
strSQL =
"INSERT INTO CoinCollection " +
" (ID, TypeOfCoin, YearOfCoin, StateOfCoin, DateReceive)" +
"VALUES " +
" (@ID, @TypeOfCoin, @YearOfCoin, @StateOfCoin, @DateReceive)";
}
else
{
// The user is updating an existing item
strSQL =
"UPDATE CoinCollection " +
" SET TypeOfCoin = @TypeOfCoin, " +
" YearOfCoin = @YearOfCoin, " +
" StateOfCoin = @StateOfCoin, " +
" DateReceive = @DateReceive " +
"WHERE ID = @ID";
}
SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["connString"]);
SqlCommand cmSQL = new SqlCommand(strSQL, conn);
// Add all the requuired SQL Parmeters.
cmSQL.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int)).Value = Convert.ToInt32(tbID.Text);
cmSQL.Parameters.Add(new SqlParameter("@TypeOfCoin", SqlDbType.VarChar, 50)).Value = tbToc.Text;
cmSQL.Parameters.Add(new SqlParameter("@YearOfCoin", SqlDbType.VarChar, 50)).Value = tbYoc.Text;
cmSQL.Parameters.Add(new SqlParameter("@StateOfCoin", SqlDbType.VarChar, 50)).Value = tbSoc.Text;
cmSQL.Parameters.Add(new SqlParameter("@DateReceive", SqlDbType.VarChar, 50)).Value = tbDr.Text;
try
{
conn.Open();
cmSQL.ExecuteNonQuery();
strMsg = "Coin successfully saved to the database.";
}
catch(Exception exp)
{
strErrorMsg = "Database error! Coins not saved to database. Error Message: " + exp.Message;
}
finally
{
conn.Close();
btnAdd.Enabled = true;
}
}
bhumber
|
|
|
|
|
the btnAdd.Enabled = true; line is in the finally block so it will always run. You might want to put that in the try block.
Also if you do this:
int intAffectedRecords = cmSQL.ExecuteNonQuery();
you can get the count of affected records so you could then say if there were records affected the button would be enabled:
btnAdd.Enabled = (intAffectedRecords > 1) ? true : false;
You can also just use the Exception exp's ToString method to see the entire error message:
Response.Write(exp.ToString());
Dirk Watkins
|
|
|
|
|
i have some confusion. Scenario is that for an Employee to
start and end job the following fields are available;
Field DataType
===== ========
Emp_Id Foreign Key}
DateTime PrimaryKey }----> Composite Primary key
CheckInTime DateTime
CheckOutTime DateTime
InOutStatus bit
HoursWorked ?--------> What shoulud be DataType?
When an Employee Checks in All fields are set and
InOutStatus is set to 1 Except CheckOutTime and
HoursWorked.When The Employee checks out InOutStatus is set
to 0,CheckOutTime is set and then i have to calculate the
HoursWorked (TimeDuaration). Constarins are CheckOutTime is
always greater than CheckInTime.(There may be different
dates for them as employee gets check in ,Nov 29,2005 on
time 17:00 and checksout , Nov 30,2005 on time 03:30).Now
according to calculation he worked for 10 hours and 30
minutes .How to calculate this hours worked(only time
duration and to which datatype it should be saved in sql)
as well as the Stored Procedure for this whole
process.Whenever Employee comes his Emp_Id is only known.
Thnx in Advance.
|
|
|
|
|
If minute level precision is fine then save the number of minutes and use int as datatype.
Declare @dt1 datetime, <br />
@dt2 datetime<br />
<br />
Set @dt1 = GetDate()<br />
Set @dt2 = DateAdd(yyyy, 1, @dt1)<br />
<br />
select DATEDIFF(mi, @dt1, @dt2)
Farhan Noor Qureshi
if (this == this) thow this;
|
|
|
|
|
Hello developer, i don't become the primary key back.
Whats wrong? The returnvalue is always sero.
C#-Code:
class vers
{
OleDbConnection connection = new OleDbConnection(ConnectionString);
....
public void Eintragen(sql)
{
OleDbCommand myOleDbCommand = new OleDbCommand(sql, connection); myOleDbCommand.ExecuteNonQuery();
myOleDbCommand = new OleDbCommand("SELECT @@IDENTITY", connection);
return Convert.ToInt32(myOleDbCommand.ExecuteNonQuery());
}
}
|
|
|
|
|
This will only work once a new identity has been created or changed should only be used within a stored procedure.
Remarks
After an INSERT, SELECT INTO, or bulk copy statement completes, @@IDENTITY contains the last identity value generated by the statement. If the statement did not affect any tables with identity columns, @@IDENTITY returns NULL. If multiple rows are inserted, generating multiple identity values, @@IDENTITY returns the last identity value generated. If the statement fires one or more triggers that perform inserts that generate identity values, calling @@IDENTITY immediately after the statement returns the last identity value generated by the triggers. The @@IDENTITY value does not revert to a previous setting if the INSERT or SELECT INTO statement or bulk copy fails, or if the transaction is rolled back.
INSERT INTO jobs (job_desc,min_lvl,max_lvl)
VALUES ('Accountant',12,125)
SELECT @@IDENTITY AS 'Identity'
|
|
|
|
|
In sql database , I have two tables named Emp_Info and Emp_Experience
the structure of table is like this;
Emp_Info
========
Emp_Id PrimaryKey(Auto)
Emp_Name
Emp_Age
Emp_Experience
==============
Exp_Id PrimaryKey(Auto)
Emp_Id ForeignKey
Exp_Detail
Exp_Year
. . . . ... and so on
Working on a single form, All these fields have to be enterd and are saved against one button click.The Problem is how can i get the Emp_Id for Emp_Experience table to save Experince and Emp_Info paralelly.The relationship btw Emp_Info and Emp_Experience is one to many. that is, Against one Employee there may be none or many Experiences.
in the scenario, i have to add Experiences first and then save the Employee? What 2 do? any guide line, help .....>?
i need its stored procedure for saving Experiences.
Thnx in Advance
|
|
|
|
|
Use something like,
1. Insert Into Emp_Info............
2. Store newly created auto generated id in a local variable as,
Select @newId = @@IDENTITY
3. Insert Into Emp_Experience....... and use @newId as fk here
Farhan Noor Qureshi
if (this == this) thow this;
|
|
|
|
|
I need to save a record with 8 fields in my sql server table to be exact.
Which of the method is recommended and faster with this scenario.
1. Insert the record using the normal insert statement.
OR
2. Insert the record using the stored procedure (I will create the insert statement inside the stored procedure) call it in my program and pass the insert parameters.
Regardless of Security.. One record at a time using web application.
Thanks
|
|
|
|
|
A combination of command object with stored proc is usually faster than even with very simple dynamic sql.
dabuskol wrote: (I will create the insert statement inside the stored procedure)
Will your INSERT statement be dynamic for each call? If thats the case then it may not be a good idea to use a stored proc.
Farhan Noor Qureshi
if (this == this) thow this;
|
|
|
|
|
I want to use an Access database for my website (with ASP .NET). This database will have about 50,000+ records. Will an Access database be robust to withstand so many records on a web-server and be fast and efficient? For some reasons, I do not want to use SQL Server or MSDE.
Regards
-- modified at 7:12 Monday 28th November, 2005
|
|
|
|
|
Rama Sharma wrote: Will an Access database be robust to withstand so many records on a web-server and be fast and efficient?
MS Access is not designed for such a scenario and IMHO MS Access is an oxymoron to robust-fast-efficient
Farhan Noor Qureshi
if (this == this) thow this;
|
|
|
|
|
Farhan Noor Qureshi wrote: MS Access is not designed for such a scenario and IMHO MS Access is an oxymoron to robust-fast-efficient
Yes, Access is indeed an oxymoron.
Why is it that you do not want to use MSSQL or MSDE? You may want to look at migrating from Access to either of these, or to MySQL or Firebird...
Paul
|
|
|
|
|
Thanks for your reply.
But, will MySQL be good and efficient for such a job?
|
|
|
|
|
Rama Sharma wrote: will MySQL be good and efficient for such a job?
It could. Mileage can vary with alot of things. I've found MySQL to work just fine under both Linux and Windows. Firebird is something I have found interesting. I am not sure as to what your requirements are for your website/database, but I hope this can help shed some light.
|
|
|
|
|
Rama Sharma wrote: Will an Access database be robust to withstand so many records on a web-server
I don’t do any web type stuff, but I do have an app with access as its database with a few hundred thousand records. It works with no problems, the bottle neck with my app isn’t the database it’s the 4 Meg token ring network.
BTW, I would rather use SQL Server, but getting access to one in the corporation I work for is insane.
If data security is of importance then go with SQL Server, Access for all intense purposes has no security.
ZeePain! wrote: This seems like one of those programs that started small, grew incrementally, building internal pressure, and finally barfed all over its source code sneakers. Or something.
thedailywtf.com[^]
-- modified at 3:09 Tuesday 29th November, 2005
|
|
|
|