|
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.
|
|
|
|
|
|
Hi,
I have a problem, I need to move large numbers of data/multiple tables from a Mainframe DB/2 to a SQL server.
What is the best possible way?
Can I use VB.NET and dataadapers to do this? The larger tables consists of more than 25 milj. rows.
Happy to get any kind of help
Regards
JPalm
|
|
|
|
|
|
Hi,
In a disconnected dataset (dsAdressen) I have to search for a specific record. I want to do this with it's Primary Key (PK).
At designtime I created a connection (cn), dataadapter (daPersonen) and dataset (dsAdressen)
When loading the form I do the following
cn.open
daPersonen.Fill(dsAdressen)
cn.close
When I try to search for a specific record with it's primary key I use code like
dsAdressen.Personen.FindByPersoonsID(1)
When I show the found value in a messagebox it's showing the right record
MsgBox(dsAdressen.Personen.FindByPersoonsID(1).Voornaam)
but my textbox, for which I set the databindings property at designtime in the property pane (txtVoornaam=dsAdressen.Personen.Voornaam), does not show the found value. I thought that by setting this property my textbox should automatically show the found value in the dataset.
I can use code like this to show the value in the textbox, but I should say that is not the way
dim dr ad Datarow
dr = dsAdressen.personen.rows.find(1)
txtVoornaam.text = dr("Voornaam")
I do not understand
Thanks
Hendrik Jan
|
|
|
|
|
Try using a CurrencyManager
Dim cm as CurrencyManager = CType(Me.BindingContext(table), CurrencyManager)
table.DefaultView.Sort = "PrimaryKey"
cm.Position = table.DefaultView.Find(PK)
This should cause value in the selected row to display in the databound TextBox
Darrell A Escola, MCDBA, MCAD
|
|
|
|
|
Is someone know the way to generate Insert script of a couple of selected record in a databae ? To after execute to script on another databse/server ?
sebastien.lachance.blogspot.com
|
|
|
|