|
The general method would be to import the text file (csv) into Access (into a temporary table), then manipulate the data from the temporary table into the correct locations using queries/code etc.
-------------------------------------------
Don't walk in front of me, I may not follow;
Don't walk behind me, I may not lead;
Just bugger off and leave me alone!!
|
|
|
|
|
Hi everyone.
I'm making a custom tool for registering working hours for my employer against a Visual FoxPro database.
I've created a procedure for executing sql queries against the database, but my insert statments aren't commited.
The return value (affected rows) says that the query was successfull.
I'm using a normal "insert into (col1, col2, col(n)) VALUES(val1, val2, val(n))" statement - so nothing fancy.
I've tried using transactions and myTransaction.Commit(); without success.
I've also tried using keywords like "GO" or "COMMIT" in the query - but the FoxPro ODBC driver isn't too keen on those keywords.
Am I missing something here?
I thought ODBCCommand.ExecuteNonQuery() used the auto-commit property.
Is there and specific properties that must be set, or keywords I must include to make it commit?
Sidenote:
If I copy/paste the query into an ODBC tool (freeware tool I just downloaded for testing purpouses) and execute the query,
the row is added successfully.
I'd really appreciate any feedback you've got.
-Larantz-
-- modified at 5:18 Monday 22nd October, 2007
I copied the database into a cvs folderstructure the other day.
Forgot to update the configuration file with the connectionstring the very next day...
*humble Larantz signing out*
-Larantz-
|
|
|
|
|
Hello.
I have a _CommandPtr that has the type CommandTypeEnum::adCmdTex, and the CommandText a query("Select test from Table_1") and this select returns one row and one column that has a binary data(image) in it.
<br />
CommandPtr pCommand;<br />
pCommand.CreateInstance(__uuidof(Command)); <br />
pCommand->ActiveConnection = this->pConnection;<br />
pCommand->CommandType = CommandTypeEnum::adCmdText;<br />
pCommand->CommandText = _bstr_t("select test from Table_1"); <br />
<br />
pRecordset = pCommand->Execute(NULL,NULL,CommandTypeEnum::adCmdText); <br />
BYTE* buffer = NULL;<br />
if(pRecordset != NULL)<br />
{<br />
while (!pRecordset->GetEndOfFile())<br />
{<br />
VARIANT var = pRecordset->Fields->GetItem("test")->Value;<br />
void * pData = NULL;<br />
SafeArrayAccessData(var.parray, &pData);<br />
long size = GetArraySize(var, NULL);<br />
buffer = new BYTE[size];<br />
memcpy(buffer, pData, size);<br />
SafeArrayUnaccessData(var.parray); <br />
pRecordset->MoveNext();<br />
}<br />
pRecordset->Close();<br />
}<br />
where
<br />
long GetArraySize(const VARIANT& var, long * nElems)<br />
{<br />
if ( !(var.vt & VT_ARRAY) ) return -1; <br />
<br />
long size = 0;<br />
long dims = SafeArrayGetDim(var.parray);<br />
long elemSize = SafeArrayGetElemsize(var.parray);<br />
long elems = 1;<br />
for ( long i=1; i <= dims; i++ )<br />
{<br />
long lbound, ubound;<br />
SafeArrayGetLBound(var.parray, i, &lbound);<br />
SafeArrayGetUBound(var.parray, i, &ubound);<br />
elems *= (ubound - lbound + 1);<br />
}<br />
<br />
if ( nElems ) *nElems = elems;<br />
<br />
size = elems*elemSize;<br />
return size;<br />
}<br />
When I debug the application, I get the record in the VARIANT var = pRecordset->Fields->GetItem("test")->Value; but when I put par.parray in Memory explorer in VS, i only see this data "fe ee fe ee fe ee fe ee fe ee fe ee fe ee ...fe ee" and of course it brakes at
SafeArrayGetLBound(var.parray, i, &lbound);
Can someone tell me where I am doing a very bad thing?
P.S. I was able to read the binary data correctly from the server using C#.NET 2.0.
Eusebiu
|
|
|
|
|
I found the solution... it's the GetChunck method....
<br />
if(pRecordset != NULL)<br />
{<br />
while (!pRecordset->GetEndOfFile())<br />
{<br />
ADO_LONGPTR size = pRecordset->Fields->Item["test"]->ActualSize;<br />
<br />
BYTE* buffer = new BYTE[size];<br />
_variant_t varChunk;<br />
varChunk = pRecordset->Fields->Item["test"]->GetChunk(size);<br />
<br />
BYTE * pData = NULL;<br />
SafeArrayAccessData(varChunk.parray, (void HUGEP* FAR*)&pData);<br />
memcpy(buffer, pData, size);<br />
SafeArrayUnaccessData(varChunk.parray);<br />
<br />
ofstream myFile ("C:\\Blue hills.jpg", ios::out | ios::binary);<br />
myFile.write((char*)buffer, size);<br />
myFile.flush();<br />
<br />
pRecordset->MoveNext();<br />
}<br />
pRecordset->Close();<br />
}<br />
<br />
Eusebiu
|
|
|
|
|
Send all the sql queries for programming
|
|
|
|
|
SreejithAchutan wrote: Send all the sql queries for programming
SELECT ...
DELETE ...
UPDATE ...
INSERT ...
EXEC ...
Fill in the blanks to get desired results.
|
|
|
|
|
sometimes people just don't get it even when you are very clear about what you want. Could you please tell what Sql queries do someone has to send?
Regards - J O N -
|
|
|
|
|
Check your Answer
SreejithAchutan wrote: Subject:Re: SqlQueries
SqlQueries[^]
SreejithAchutan wrote: sql queries for programming
sql queries for programming [^]
B Specific and Clear About Your Question
|
|
|
|
|
Use Google
enjoy with Googling.... you will get everything
Pavan Pareta
|
|
|
|
|
if i run my view in the Designer at hte Enterprise manager i get that error message.. but if i run it through the SQL analyzer it's fine it wont have any errors..
|
|
|
|
|
You are Using any field which is keyword
so use all field name with [] ex//
Select name,group from employee
Select [name],[group] from [employee]
Best Regards,
Chetan Patel
|
|
|
|
|
ei tnx so much..
at least now i got a hint cause i dont know where to start fixing that error..
|
|
|
|
|
In a transaction block if any error for insert or update occures (e.g. caused by foreign key-primary key constraint violation) does the transaction automatically rolls back or do we need to manually roll it back ?
|
|
|
|
|
Syntax will go like this:
<br />
Begin Try<br />
Begin Transaction<br />
--Your Line of code<br />
Commit Transaction<br />
End Try<br />
Begin Catch<br />
RollBack Transaction<br />
End Catch<br />
--Your line of code<br />
You will have to call commit or rollback for your transaction.....
|
|
|
|
|
Does such syntax really exist ? I am using SQL Server 2000. and I get error when runnig such code.It doesn't know TRY keyword.
|
|
|
|
|
It will rollBack "autopmatically" if you will say so.
E.G.
BEGIN TRAN
your code
if @@error <> 0 goto err
-- more code
if @@error <> 0 goto err
At the end:
commit tran<br />
return 1<br />
<br />
err:<br />
rollback tran<br />
return 0
Sincerely,
Elina
Life is great!!!
Enjoy every moment of it!
|
|
|
|
|
Am developing a online shopping website.I need to develop a search engine that would search items based on its catogery(example i want to search any particular book such as ASP.NET or C# from book catogery).So i want information on what are the search engines available that would best suit to my project.Please help me out..
Thank you...
sandeephs
|
|
|
|
|
do you want to desgin search engine for your site only? means will search only your site content?
kindly explain !!!!
|
|
|
|
|
Hallo;
I would Like to know how to select last insert id from one table so as i can insert it to another table on the same event holder using SQL SERVER 2000 /2005
I am able to do the same using Mysql using the last insert Id function but cannot do the same for SQL server.
briogene
|
|
|
|
|
with the help of
@@identity
and
u can use this query as well
select max(id) from tablename
After the insertion of values
I hope this will work for u
Regards
Avesh
|
|
|
|
|
thanks for this avesh it works
briogene
|
|
|
|
|
Your Welcome...
Regards
Avesh
|
|
|
|
|
You really shouldn't do either of these, as they are both pretty bad practice. If you do a select on @@identity, you get the last inserted identity column regardless of scope. So, suppose you insert a record into your table and there is a trigger behind there that inserts into another table with an identity column on it, @@identity returns the id of the trigger insert and not the main table.
SELECT max(id) only works if there aren't multiple people posting into your tables at the same time.
The simple solution is to use:
SELECT @ID = SCOPE_IDENTITY() This returns the identity of the inserted item on the main table, even if you have lots and lots of trigger inserts going on.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Select scope_identity()
-- modified at 5:31 Monday 22nd October, 2007
Best Regards,
Chetan Patel
|
|
|
|
|
Hi Everyone,
I have a file named as "File1.txt" from "MachineA" that is under shared folder only. But my SQL SERVER 2000 is in "Machine B". I am doing sending from SQL Server 2k using Jmail.
I want to access the network file "File1.txt" from "MachineA".
If, I give machine name or ip. it doesn't take. simply it skips the attachment file and it sending only mail. If i stored the "File1.txt" in "MachineB" then its sending correct.
Please give me some idea.....
Thanks & Regards
Kumaran
|
|
|
|