Distinct in SQL Query

Status
Not open for further replies.

Bahatmut

Active member
Joined
Jun 14, 2005
Messages
29
Location
NY
Programming Experience
Beginner
Distinct in SQL Query-Problem Resolved

I am writing a more ecomplex program than my previous one, one requiring parsing out dinstinct entries from a table (there are about 5 distinct values in on column across 36000 records). Here is my question.

I am using the OleDbDataReader to retrieve the data, my query is

SELECT DISTINCT Category FROM Videos

However, every time I try and execute the reader, the debugger fails. It says that all needed components (Query string, Connection String, and Command) are correct, but it still fails.


And PLEASE don't rip into me for failure to use that POS the MS calls the DataAdapter/DataSet, it's like trying to read cyrillic languages crosseyed and expecting people to get it. (No offense to anyone who native can read cyrillic). Besides, I have NO NEED for a data grid, I am merely trying to populate 4 combo boxes from the database.
 
Last edited:
mistake in words.

My mistake was using the word update. The routine is NOT updating, it is inserting a totally new, unique record, which to my understanding of the help files is done by the INSERT, not the UPDATE SQL. And no offense, but as for now, as I very very barely understand even the string.format, please stop reccomending new things when what I do semi-understand doesn't work yet.
 
<sigh>

No offense to your small program, but in NO WAY does it even begin to answer WHY my code keeps failing. Having a little feep program to demostrate the Insert and Update is all fine and good, but when the structure of your code is almost identical to my in terms of trying to actually execute the insert, it doesn't help identify where/what the problem is. I have already said I have verified that the actuall Insert srting IS COMPLYING with every single refrence I have been able to find in both the MSDN library and the Visual Studio help system. I am inserting 13 values, I am giving it 13 valid vales, the names fo the fields line up, the structure of the OLEDBCommand and Connection are correct. Yet it STILL fails on the UpdCmd.ExecuteNonQuery()
 
It may be the fact that you are trying to insert date fields without telling it they are dates. If you want to include a literal date in an SQL statement it needs to be enclosed in "#" characters, just like a string gets enclosed in single quotes. Try that and if it still doesn't work I'll look a little deeper.
 
Thank you.

Thank you, that fixed the problem, and I was able to get the rest of the small issues to iron out.
 
Back there and take a look how you start your thread ... you didn't know to deal with executeScalar from beginning and now you are telling me "No offense" ... hahahaha '

btw, you can insert date dt without those #s but that's another story ... this thread is closed for further posting. Lucky you that John told you the right tips :)

Regards ;)
 
Status
Not open for further replies.
Back
Top