|
Yes, SQL Server.
Fair point, just my natural tidiness
Anyway, dropping the drops doesn't solve the issue....
Cheers
Ben
|
|
|
|
|
The reason you are getting this error is because you cannot use temp tables with DTS packages.
This is because DTS packages cannot resolve temp tables in design time.
This is a 'feature' of SQL Server 2000.
My advice is not to use temp tables with the DTS package.
What I do is pipe the result of the stored procedure to a table then call the DTS package from within a stored procedure (using the freshly populated table in the DTS package).
You can then drop the table or delete the rows once the DTS package has been run.
Alternatively if you really want to use temp tables check out this link where I explain how to get around this problem.
The solution is not pretty.
Basically my advice is to avoid temp tables with DTS packages - this is a documented 'feature'.
I hope this helps.
-- modified at 16:32 Tuesday 23rd October, 2007
-- modified at 16:33 Tuesday 23rd October, 2007
You always pass failure on the way to success.
|
|
|
|
|
Thanks for the pointer. Seems most odd that that this isn't supported - is there a reason they opted not to allow this?
Cheers
Ben
|
|
|
|
|
Bjohnson33 wrote: Seems most odd that that this isn't supported
Yes this is what we call a 'bug' and microsoft calls a 'feature'
What I tend to do nowadays is always pipe the results into a table then run the DTS from one table.
This has a tendency to simplify things a lot as processes, including file copying etc, are visible within the stored procedure and not hidden within the DTS package (I avoid the DTS vb scripting feature as although it looks good - try debugging a DTS package with all that code hidden away in various places).
You always pass failure on the way to success.
|
|
|
|
|
How can we reset the start of an identity column.
|
|
|
|
|
Use DBCC CHECKIDENT (tablename, RESEED, 9999) . This would reset the next identity to 10000 on the table in question.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Use DatabaseName
DBCC CHECKIDENT (tablename, RESEED, 0)
OutPut : reset the column identity next value start to 1
Mitesh Darji
|
|
|
|
|
Hi there,
Well it seems I have stumbled upon a rather basic problem and I just cant seem to work it out. I have written a simple update query as follows:
<br />
private readonly string ACCESS_CUSTOMER_UPDATE = "UPDATE Customer SET Customer.Name = @Name,Customer.Age = @Age WHERE Customer.ID = @ID";<br />
I have used the approach to execute the query in the method listed below. For the life of me I cant seem to work out why the update wont be taking place. I have executed the query listed above in Access without any problems but when encapsulated in the method below it just wont update.
I'd appreciate if someone could point out the mistake I have overlooked.
Thanks
<br />
private string PARAM_ID = "@ID";<br />
private string PARAM_NAME = "@Name";<br />
private string PARAM_AGE = "@Age";<br />
<br />
private string connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Temp\\temp.mdb";<br />
<br />
private OleDbConnection connection = new OleDbConnection(connectionstring);<br />
<br />
public void UpdateCustomer(CustomerInfo customer)<br />
{<br />
OleDbParameter[] parameters = new OleDbParameter[]{<br />
new OleDbParameter(PARAM_ID,OleDbType.Integer),<br />
new OleDbParameter(PARAM_NAME,OleDbType.VarChar),<br />
new OleDbParameter(PARAM_AGE,OleDbType.Integer)};<br />
<br />
parameters[0].Value = customer.ID;<br />
parameters[1].Value = customer.Name;<br />
parameters[2].Value = customer.Age;<br />
<br />
OleDbCommand command = new OleDbCommand();<br />
command.Connection = this.connection;<br />
command.Connection.Open();<br />
command.CommandText = "UPDATE Customer SET Customer.Name = @Name,Customer.Age = @Age WHERE Customer.ID = @ID";<br />
<br />
for (int i = 0; i < parameters.Length; i++)<br />
{<br />
OleDbParameter parm = (OleDbParameter)parameters[i];<br />
command.Parameters.Add(parm);<br />
}<br />
<br />
try<br />
{<br />
int x = command.ExecuteNonQuery();<br />
Debug.WriteLine(x.ToString());<br />
}<br />
catch (Exception e)<br />
{<br />
throw new Exception(e.Message, e.InnerException);<br />
}<br />
finally<br />
{<br />
command.Connection.Close();<br />
command.Dispose();<br />
}<br />
}<br />
edit:
Added the connection string.
|
|
|
|
|
Can you also write the error which you are getting?
Arun Singh
Noida.
|
|
|
|
|
I think that you're going to find that the order of the parameters going into your oledbcommand for access is important...
|
|
|
|
|
I am getting no error. The output of ExecuteNonQuery is an "int" type. The value of this int variable indicates how many rows have been modified. In my case its zero when infact it should be one. I have one row of data in the table that needs to be updated so it should return 1 not 0.
I can verify that order of parameters matches what is in the table.
Any other suggestions I can try out ?
Edit:
Running the code like this works fine:
<br />
public void UpdateCustomer(CustomerInfo customer)<br />
{<br />
string query = "UPDATE CUSTOMER SET Name = " + "'" + customer.Name + "'," + "Age = " + customer.Age + " WHERE ID = " + customer.ID;<br />
OleDbCommand command = new OleDbCommand();<br />
command.CommandText = query;<br />
command.Connection = this.connection;<br />
command.Connection.Open();<br />
try<br />
{<br />
int x = command.ExecuteNonQuery();<br />
Debug.WriteLine(x.ToString());<br />
}<br />
catch (Exception ex)<br />
{<br />
throw new Exception(ex.Message, ex.InnerException);<br />
}<br />
finally<br />
{<br />
command.Connection.Close();<br />
command.Dispose();<br />
}<br />
}<br />
|
|
|
|
|
UPDATE Customer SET Customer.Name = @Name,Customer.Age = @Age WHERE Customer.ID = @ID
private string PARAM_ID = "@ID";
private string PARAM_NAME = "@Name";
private string PARAM_AGE = "@Age";
What i think you'll find is happening here is that the sql statement is being executed and is trying to set name = id, age = name where id = age. Awkward problem.
|
|
|
|
|
Your problem is with the order of your parameters. System.Data.Oledb does not work like sqlclient (or Access internally) The parameter names are irrelevant, only order matters.
change your parameters to:
parameters[0].Value = customer.Name;
parameters[1].Value = customer.Age;
parameters[2].Value = customer.ID;
So that they match the order of occurrence in the query.
|
|
|
|
|
Thanks for the tip, I'll have to makesure I am more observant next time
|
|
|
|
|
i have two tables .They are related by primary key,foreign key constrain.If i want to delete few rows in primary table without deleting corresponding rows in foreign key table . How will i do it.
|
|
|
|
|
hey whenever u delete a row it is copied somewhere exactly i dont know but we can retrive it back do some R and D u can do it easily
its me sid
|
|
|
|
|
How does this relate to the question being asked? The question was about the primary/foreign key contraint that exists between the 2 tables, not about retrieving the deleted rows from the primary key table.
Paul Marfleet
|
|
|
|
|
Try and give your posts more meaningful titles. 'Delete' is too vague. Read the forum guidelines.
Why would you want to do this if you have defined constraints between the 2 tables? One of the reasons for defining such a constraint is to prevent orphaned records remaining in the foreign key table when a primary key record is deleted. If you don't want such a constraint to exist, remove it.
Paul Marfleet
|
|
|
|
|
ritu4321 wrote: If i want to delete few rows in primary table without deleting corresponding rows in foreign key table . How will i do it.
Don't define any constraints between the two tables
|
|
|
|
|
i want to keep the constrain as it is but want to delete the row how will i do it.
|
|
|
|
|
ritu4321 wrote: i want to keep the constrain as it is but want to delete the row how will i do it.
Then what will be use of the constraint ? Why you need to do this ? Once the delete cascade is given, it will remove the foreign key values too.
|
|
|
|
|
|
Do you understand the purpose of such a constraint? It is there to enforce referential integrity between 2 tables, so values in the foreign key field in the related table must exist in the primary key field in the main table. If you don't want to enforce referential integrity, delete the constraint. It doesn't serve any purpose otherwise.
Paul Marfleet
|
|
|
|
|
Once values should the child table's contain i.e. when the parent key value is removed then what value should be there in child key.
can you give more clarity with some examples
Regards
KP
|
|
|
|
|
hi i know that storing a image in a database is not a correct option but requirement is like that so if anyone is having any idea please let me know
i know few thing abt access that the datatype must be ole object and i know how to get back the image so storing is only the problem
i hope i am clear
thank u
sindhu tiwari
its me sid
|
|
|
|