|
I believe there is a property of the image that can be set to 'External' that allows you to use the value to refer to a location; however, this may only work with a URL location or perhaps in UNC format. Sorry, but I don't recall the name of the property off-hand.
Keep It Simple Stupid! (KISS)
|
|
|
|
|
Anyone have simple source code to work with OleDb database such as write data into table?
thanks
|
|
|
|
|
There are loads of examples on CP and Google. Its quicker to go to google and type "OleDb insert" than it is to post your question here and wait for an answer. If you want to make a living as a developer then remember google is your friend.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Ashfield wrote: Its quicker to go to google and type "OleDb insert"
Had to try: approximately 252 000 hits.
|
|
|
|
|
Mika Wendelius wrote:
Had to try: approximately 252 000 hits.
There is bound to be something very good in all of that
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
I would guess so
|
|
|
|
|
I am interested in knowing whether it is possible to coordinate two database transaction using Distributed Transaction Coordinator (MSDTC).
Any reference would be good.
Thanks,
Perry
|
|
|
|
|
paresh_joe wrote: whether it is possible to coordinate two database transaction using Distributed Transaction Coordinator
Could you clarify this with a scenario.
modified on Tuesday, December 2, 2008 5:48 AM
|
|
|
|
|
Hello,
Some quick questions to help me in my investigation...
Is it possible for triggers not to execute when the performance is poor?
The scenario is this, we have a trigger on table A that copies data to table B whenever an insert/update is done on table A.
However, when we were having performance problems with the server, it seems like the trigger did not execute. This looks like the case because the data was successfully inserted in table A but it is not found in table B.
What could have been the problem?
Also, is it possible for the trigger to roll back the insert on table A if it fails? How can I do this?
Thank you in advance.
Rafferty
|
|
|
|
|
Rafferty Uy wrote: Is it possible for triggers not to execute when the performance is poor?
No, unless there's a bug in SQL Server.
Rafferty Uy wrote: is it possible for the trigger to roll back the insert on table A if it fails
Yes it is. By executing rollback statement which rolls back the entire transaction.
|
|
|
|
|
I see.
What I meant with roll back is... for example I run a stored procedure AddToTableA, which executes a trigger TableAInsertTrigger.
How can I write TableAInsertTrigger in such a way that, if it fails, it will also roll back the AddToTableA SP?
Rafferty
|
|
|
|
|
|
So, if I get this correctly... for example given the following SP and Trigger
CREATE PROCEDURE AddToTableA() AS
BEGIN
BEGIN TRANSACTION
INSERT INTO TableA VALUES(1, 'SomeValue')
IF (@@ERROR <> 0) GOTO ERR_HANDLER
COMMIT TRANSACTION
RETURN 0
ERR_HANDLER:
ROLLBACK TRANSACTION
END
CREATE TRIGGER TableAInsertTrigger ON TableA FOR INSERT
BEGIN
INSERT INTO TableB (SELECT * FROM INSERTED)
-- do something else here, one that causes error
END
In the above case, if I call AddToTableA() and since TableAInsertTrigger fails, it will roll back the inserts on both TableB (in the Trigger) and TableA (in the SP)?
btw, thank you for helping
Rafferty
|
|
|
|
|
Rafferty Uy wrote: In the above case, if I call AddToTableA() and since TableAInsertTrigger fails, it will roll back the inserts on both TableB (in the Trigger) and TableA (in the SP)?
Yes, exactly. The insert statement in the trigger is inside the same transaction as the insert that fired the trigger. This is why if you roll back the transaction, also trigger modifications are rolled back.
It's easy to test if you create an error in the end of the trigger (for example set @variable = 1/0), you can see what happens.
Rafferty Uy wrote: btw, thank you for helping
No problem
|
|
|
|
|
Thanks again!
btw, just another quick question. If I do the condition above... does it mean that the SP will no longer raise an error?
For example, if I have another SP calling AddToTableA() , and let's say that this other SP has an if...else statement depending if AddToTableA() causes an error, will AddToTableA() still return an error when it already handled the @@ERROR and executed a ROLLBACK TRANSACTION ?
Rafferty
|
|
|
|
|
When you execute RAISERROR in a stored procedure, the caller will see an error as a result, regardless who is calling the block. So even if you catch the error, the RAISERROR generates a 'new' one.
If the SP has executed rollback then there's no transaction left so be sure that you don't make any modifications since they would not be part of the original transaction.
Also, if I remember correctly, you cannot execute ROLLBACK again since it would generate a different error (no transaction or such).
I think it would be good if you create a test situation and try different variations in order to find the one that suits you best.
Mika
|
|
|
|
|
okay, thanks a lot!
Rafferty
|
|
|
|
|
No problem
|
|
|
|
|
I have this error "ExecuteReader: Connection property has not been initialized."
Here is my code . Could give me any advice to fix it ?Thanks
private void button1_Click(object sender, EventArgs e)
{
string cmd;
string field;
string parameter;
field = "Site,Model";
parameter = "@Site,@Model";
OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\db1.mdb");
cmd = "INSERT INTO Run(" + field + ") values (" + parameter + ")";
OleDbCommand sCommand = new OleDbCommand(cmd);
aConnection.Open();
OleDbDataReader aReader = sCommand.ExecuteReader();
sCommand.Parameters.Add("@Site", OleDbType.VarChar, 20);
sCommand.Parameters.Add("@Model", OleDbType.VarChar, 20);
sCommand.Parameters["@Site"].Value = "site1";
sCommand.Parameters["@Model"].Value = "Model1";
aReader.Close();
aConnection.Close();
}
|
|
|
|
|
Below is the change in bold to do in your code:
private void button1_Click(object sender, EventArgs e)
{
string cmd;
string field;
string parameter;
field = "Site,Model";
parameter = "@Site,@Model";
OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\db1.mdb");
cmd = "INSERT INTO Run(" + field + ") values (" + parameter + ")";
OleDbCommand sCommand = new OleDbCommand(cmd);
aConnection.Open();
sCommand.Connection = aConnection
OleDbDataReader aReader = sCommand.ExecuteReader();
sCommand.Parameters.Add("@Site", OleDbType.VarChar, 20);
sCommand.Parameters.Add("@Model", OleDbType.VarChar, 20);
sCommand.Parameters["@Site"].Value = "site1";
sCommand.Parameters["@Model"].Value = "Model1";
aReader.Close();
aConnection.Close();
}
Hope this solves your problem
|
|
|
|
|
thanks. but another error occur:
No value given for one or more required parameters.???
|
|
|
|
|
Why are you creating an OleDbDataReader for an INSERT statement? It makes no sense since reader is used when you fetch data from the database.
Also you execute the command before setting any parameters or their values.
|
|
|
|
|
I'm having a little bit of brain fry going on...
How can I go about to see if any date within a date range is in another date range?
Example: Is any date between 01/01/2008 - 12/31/2015 in 11/21/2008 - 12/21/2009?
MOD:
Ok, so I think I found my answer. Does anyone see an issue with this comparison?
01/01/2008 < 12/21/2009 AND 12/31/2015 > 11/21/2008 [obviously these would be parameters and fields in a database.... paramStart < dbEnd AND paramEnd > dbStart]
modified on Monday, December 1, 2008 3:09 PM
|
|
|
|
|
mobius111001 wrote: Is any date between 01/01/2008 - 12/31/2015 in 11/21/2008 - 12/21/2009?
If
date1 = 01/01/2008
date2 = 12/31/2015
date3 = 11/21/2008
date4 = 12/21/2009
then it would be something like:
... date1 between date3 and date4
or date2 between date3 and date4
or (date1 < date3 and date2 > date4) ...
|
|
|
|
|
We have developed software in .net application and backhand as a SQL Server Desktop Engine. The query is how to update database at client end without disturing his live data. There is continious update going on in database structure. This is the issue we have been facing from a long time.
Thanks.
|
|
|
|