Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > .NET Languages
You last visited: Today at 20:26

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



SQL Data Reader

Discussion on SQL Data Reader within the .NET Languages forum part of the Coders Den category.

Reply
 
Old   #1




 
stotterer09's Avatar
 
elite*gold: 26
Join Date: Dec 2010
Posts: 2,628
Received Thanks: 1,816
SQL Data Reader

Hi ich habe ein Problem beim benutzen meines SQL data readers:
Das ist mein code
count ist 3
ich würde gern 3 Datensätze rausbekommen aber nach dem ersten stürzt er mir ab(der erste wird aber noch richtig gelesen)
Code:
            dwID = new object[count];

            cmd.CommandText = "SELECT dwID FROM TQCONDITIONCHART WHERE dwQuestID =" + dwQuestID.ToString() + ";";
            reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                for (int j = 0; j < count; j++)
                {
                    dwID[j] = reader.GetValue(j);

                }
            }
            reader.Close();
Ich habe keine Ahnung was ich falsch mache bitte um Hilfe^^
diese 3 datensätze sollten rauskommen:


mfg



edit: anscheinend kann man mit dem reader nur in einem Datensatz lesen
aber wie kann ich dann den 2. Datensatz auslesen?

mfg


Edit: kann zu nächstes mal lese ich die dokumentation genauer
Ich bin ein Idiot

Lösung: man springt in den nächsten datensatz mit reader.read
stotterer09 is offline  
Old 03/01/2015, 19:59   #2
 
elite*gold: 0
Join Date: Feb 2015
Posts: 31
Received Thanks: 11
Anscheinend hast dein Problem bereits gelöst.

Dennoch würde ich dir vorschlagen prepared statements zu nutzen d.h etwa so:

Code:
            dwID = new object[count];

            cmd = new MySqlCommand("SELECT dwID FROM TQCONDITIONCHART WHERE dwQuestID =@dwid;", connection);
            cmd.Parameters.AddWithValue("@dwid", dwQuestID.ToString());
            cmd.Prepare();
            reader = cmd.ExecuteReader();
            //alles andere
#[Alex]Sascha is offline  
Old 03/02/2015, 06:37   #3
 
elite*gold: 67
Join Date: Aug 2014
Posts: 1,323
Received Thanks: 928
Bitte bitte bitte mach es wie Alex.

So wie du das machst hält das auf dauer nicht. Ich spreche aus erfahung :P
Xio. is offline  
Old 03/02/2015, 17:12   #4




 
stotterer09's Avatar
 
elite*gold: 26
Join Date: Dec 2010
Posts: 2,628
Received Thanks: 1,816
Ok danke werde ich bei meinem nächsten projekt dann wohl so machen
stotterer09 is offline  
Reply


Similar Threads Similar Threads
[REQUEST]Source code for a data.sah/saf reader
01/16/2015 - Shaiya Private Server - 11 Replies
Hey fellow Devs, I was wondering if anyone had or could program a data.saf/sah reader in python, Java or C++, because I would very much need one for my programs I'm programming. I'm not sure if this is the right place to ask but I'm pretty sure some people in this community would know how to program one. If nobody has one or could program one I'll take my own chances and try to program on myself but I guess I'd be better off if I didn't have to create one myself as I merely know where to...
Reader with Foxit PDF reader is not faulty?
04/18/2014 - Technical Support - 0 Replies
Today I read a file into PDF with Foxit Reader software that error message "D: \ study \ ***********.pdf Couldnot open file. File not found " This error alone today because last week my newly found normal users do not see the error. I tried many PDF files are so off. I brought it to another computer open. You know how to help me see this error!



All times are GMT +1. The time now is 20:28.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.