|
hello
how can i deal with multivalued fields (field type = adVariant)
i need to get data from an ado recordset field with type adVariant and
convert it to string or array of strings (it is data from the ActiveDirectory
and not from sql sever !!!- the provider is 'ADSDSOObject')
i am using c++ code and working with ado on win xp
*i have found a sample how to do it in vb but can't find a way implement it in c++!!!
thank's
stanley
|
|
|
|
|
Hi All,
I have a project where I am trying to become familiar with a database app. I'd like to log the queries made against the database (an access database accessed through ADO). What's a good utility for logging database activity?
|
|
|
|
|
If I were tackling this I would try this.
With Access you can use VBA in a Trigger. (I'm not an access guru, but I know it's possible.)
Create the trigger to occur on selection
Create a FileSystemObject (Scripting.FileSystemObject) in the trigger.
Open a text file using the FileSystemObject.TextStream
Write the contents of the query to the the text file.
I'm not sure if you can pull the actual query string so you'll need to check.
I'm also not sure if this will work, but it's a good place to start.
Torin Blair
'In the immortal words of Socrates - "I drank what?".'
|
|
|
|
|
Hello, I currently have a form and within this form there is a listbox control that is displaying data from a table. The fields within this table are records in other tables in the database. I want the user to be able to double click a record in the listbox and a for will open and it will have a drop down for each column in the record and the user will be able to change the value for that column via drop down boxes that have all possible values for that field. When they are done I want to take all their new selections for the fields of this record and save it back to the table. Can anyone give me any ideas or pointers. Thanks in advance!
Frank Lepkowski
cout << "Hello World!" << endl;
|
|
|
|
|
I need to do a view to export data from SQL Server to FileMaker. So far everything is ok, but now I need to convert a value of a string to another.
I also need to do some Select case, If statement in the view to be compatible with FileMaker. Is there a way to do that in a View ?
sebastien.lachance.blogspot.com
|
|
|
|
|
Hi Sebastien. Well, I'm gleaning from your question that you may be interested in the SQL Server CASE function, which you can put in the SELECT statement for the view. Look it up in the SQL Server books online (specifically the T/SQL documentation) and see if that's what you're looking for.
Here's an article about using the CASE statement:
http://www.4guysfromrolla.com/webtech/102704-1.shtml[^]
|
|
|
|
|
I have a sample code of insert/retrieve binary file into/from MySQL, it uses FileStream to implement the function. Seems FileStream doesn't work for text file.
Can anybody tell what function should I use to retrieve text file from MySQL? Or if you could suggest a sampel code, that will be very helpful.
Thanks!
|
|
|
|
|
I don't know why a FileStream wouldn't work for text data but would for binary. Can you post your code that doesn't work so we can have a look?
Affordable and reliable hosting? Click here!
|
|
|
|
|
Hi, Davey:
Thanks for your response. Here are my code for text file:
String * NCFILE_NAME = "test10.nc";
FileStream * tfs = new FileStream(NCFILE_NAME, FileMode::Open, FileAccess::Read);
Char ncbuffer[] = new Char[(int)tfs->Length];
tfs->Read(ncbuffer, 0, ncbuffer->Length);
My intention is to read the text from "test10.nc" and write to Char Array ncbuffer[], but
tfs->Read(ncbuffer, 0, ncbuffer->Length);
cause the error like this:
cannot convert parameter 1 from '__wchar_t __gc[]' to 'unsigned char __gc[]'
When I did exactly the same for binary file, and define as:
FileStream* fs = new FileStream(FILE_NAME, FileMode::Open, FileAccess::Read);
Byte buffer[] = new Byte[(int)fs->Length];
fs->Read(buffer,0,buffer->Length);
String* extension = "jpg"; // for image file
It works fine.
So I guess maybe I should use something other than FileStream. But what is it?
Could you please give me some ideas about this?
|
|
|
|
|
Hi, Davey:
Thanks for your response. Here are my code for text file:
String * NCFILE_NAME = "test10.nc";
FileStream * tfs = new FileStream(NCFILE_NAME, FileMode::Open, FileAccess::Read);
Char ncbuffer[] = new Char[(int)tfs->Length];
tfs->Read(ncbuffer, 0, ncbuffer->Length);
My intention is to read the text from "test10.nc" and write to Char Array ncbuffer[], but
tfs->Read(ncbuffer, 0, ncbuffer->Length);
cause the error like this:
cannot convert parameter 1 from '__wchar_t __gc[]' to 'unsigned char __gc[]'
When I did exactly the same for binary file, and define as:
FileStream* fs = new FileStream(FILE_NAME, FileMode::Open, FileAccess::Read);
Byte buffer[] = new Byte[(int)fs->Length];
fs->Read(buffer,0,buffer->Length);
String* extension = "jpg"; // for image file
It works fine.
So I guess maybe I should use something other than FileStream. But what is it?
Could you please give me some ideas about this?
Regards,
Kevin
|
|
|
|
|
Always read the data into a Byte[] rather than a Char[] and it will work for both binary and text files. You shouldn't really need to read it into a char[].
Database FAQ
|
|
|
|
|
I wanted to bind the elements in a ComboBox to a column in a DataTable, but wanted them to be sorted. This application is targeted for the Compact Framework, and I didn't see a way to do that directly.
I decided to create a DataView object from the DataTable with the particular sort I was looking for. I set the DataSource of the ComboBox to the DataView, and setup the Display and Value members as needed by the app. Everything seemed to be working as expected, but I have run into one snag I can't seem to solve. If I change the name of one of the colunmns in the DataTable (ultimately the DisplayMember in the ComboBox), it doesn't propogate to the ComboBox by way of the DataView. On the other hand if I add or delete a row to the DataTable, everything does propogate to the ComboBox, even the row where I only changed the name!
Is this the expected behaviour?
Is there something I can do to force the ComboBox to reload it's drop down list?
|
|
|
|
|
This is expected behaviour.
Sadly enough there aren't any event handlers for changing column names in a DataTable object, and I believe they do not show up in the Changes collection either.
You could try re-binding the combobox when a form or control based event fires.
Torin Blair
'In the immortal words of Socrates - "I drank what?".'
|
|
|
|
|
I ended up handling the Underlying DataTable RowChanged event, and as you suggested, re-bound the combobox to the DataView. It seemed so cumbersomb that I thought there must have been a better way.
Thanks for the reply.
|
|
|
|
|
Oops... I hope I didn't mislead you... I'm not changing the column names, I'm changing the content of a column in one of the rows of the DataTable. When I do that, the new value doesn't propogate to the combobox. If I add a new row to the DataTable, everything propogates as I expected.
|
|
|
|
|
I have a VC++ application when executed gives the following message "[Microsoft][ODBC Microsoft Acess Driver]'(unknown)'". How do I fix this?
|
|
|
|
|
Looks like your ODBC connection string may be incorrect. What is it set to?
Affordable and reliable hosting? Click here!
|
|
|
|
|
below is the part where it tries to connect to the data source...and fails to connect
nConnect = SQLDriverConnect( m_hDBC, NULL, psvSource, SQL_NTS, szConnectOutput, sizeof(szConnectOutput), &nResult, SQL_DRIVER_NOPROMPT);
|
|
|
|
|
That looks OK. What is psvSource set to?
Affordable and reliable hosting? Click here!
|
|
|
|
|
_TUCHAR *psvSource=new _TUCHAR[ strlen( svSource )+1 ];
It is really weird. I've also checked in the control panel to see if the MS Access driver was listed as a data source.
May be i can email you the files? I am new to this site. Is there a way to attach the files on this site so u don't have to give your email address to me?
|
|
|
|
|
psvSource needs to be set to a DSN that you have registered in ODBC administrator. If you haven't specified one, that is probablky why you can't connect.
Database FAQ
|
|
|
|
|
Hi all
Please delight me how add store procedure file (*.sql) to my database.
Only way what i find out to add stored procedures is through Server Explorer window, but i yet had an file with ones (been generated third-part tool) and now i want to get acess to procedures which allocated in this file.
Thank.
|
|
|
|
|
Use Query Analyzer to run the script.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
I'm using ASP on a IIS server, trying to connect to a MS Access 2000 database.
All is fine until I set a database password, and then IIS tells me "Not a valid password."
I've tried using "PWD=<password>" in the ConnectionString, but the PWD key is for a user password. I found something in the microsoft KB that suggested "DATABASE PWD=<password>" might be the answer, but, alas, IIS still replies "Not a valid password."
Has anyone faced this problem before? Anyone know how to overcome it? (Other than removing the db password)
Thanks in advance for any help.
|
|
|
|
|