<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.dotnetzone.gr:443/cs/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Πρώτα Βήματα - Βάσεις δεδομένων</title><link>https://www.dotnetzone.gr:443/cs/forums/73/ShowForum.aspx</link><description>Για όσους κάνουν τα πρώτα τους βήματα στην Microsoft Access ή τον SQL Server, ή γενικότερα στη θεωρία βάσεων δεδομένων.</description><dc:language>el</dc:language><generator>CommunityServer 2.1 SP3 (Build: 20423.1)</generator><item><title>Απ: Γιατί το ίδιο ερώτημα με Parameters και χωρίς φέρνει μία reader.HasRows false και true;</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/25342.aspx</link><pubDate>Thu, 22 Feb 2007 21:54:56 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:25342</guid><dc:creator>Παναγιώτης Καναβός</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/25342.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=73&amp;PostID=25342</wfw:commentRss><description>&lt;P&gt;Δεν χρειάζεται να περνάς τίποτε επιπλέον, μόνο την τιμη της παραμέτρου. Όταν χρησιμοποιείς παραμέτρους το ADO.NET δεν χρειάζεται να μετατρέψει τις τιμές τους σε string ή κάτι άλλο για να τις στείλει στον SQL Server ή σε άλλη βάση, καθώς ξέρει ήδη πως να τις στείλει στον server. Έτσι γλυτώνεις και από προβλήματα μετατροπής ημερομηνιών και δεκαδικών, τα οποία πρέπει να αντιμετωπίζεις κάθε φορά που δημιουργείς ένα sql string με ενσωματωμένες τις τιμές των παραμέτρων&lt;/P&gt;</description></item><item><title>Απ: Γιατί το ίδιο ερώτημα με Parameters και χωρίς φέρνει μία reader.HasRows false και true;</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/25337.aspx</link><pubDate>Thu, 22 Feb 2007 20:50:07 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:25337</guid><dc:creator>dtakis</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/25337.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=73&amp;PostID=25337</wfw:commentRss><description>&lt;P&gt;Σωστή! &lt;/P&gt;
&lt;P&gt;Αν θέλω να περάσω το (') πρέπει να το κάνω στο &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:black;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;sqlCommandCheck.Parameters.AddWithValue(&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:#666666;FONT-FAMILY:Courier New;BACKGROUND-COLOR:#e4e4e4;"&gt;"@ParameterName"&lt;/SPAN&gt;, &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:#666666;FONT-FAMILY:Courier New;BACKGROUND-COLOR:#e4e4e4;"&gt;" '"&lt;/SPAN&gt;+name+&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:#666666;FONT-FAMILY:Courier New;BACKGROUND-COLOR:#e4e4e4;"&gt;"' "&lt;/SPAN&gt;);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;ή Δεν χρειάζεται να περνάω (') αν χρησιμοποιώ Parameters;&lt;/P&gt;
&lt;P&gt;Την έπαθα εντελώς σαν αρχάριος (που είμαι!)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description></item><item><title>Απ: Γιατί το ίδιο ερώτημα με Parameters και χωρίς φέρνει μία reader.HasRows false και true;</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/25336.aspx</link><pubDate>Thu, 22 Feb 2007 20:40:01 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:25336</guid><dc:creator>alexnir</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/25336.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=73&amp;PostID=25336</wfw:commentRss><description>&lt;P&gt;καποια ειναι ποιο παρατηρηρικη απο μενα &lt;img src="http://www.dotnetzone.gr/cs/emoticons/emotion-4.gif" alt="Stick out tongue" /&gt;&lt;/P&gt;
&lt;P&gt;δικιο εχεις&lt;/P&gt;</description></item><item><title>Απ: Γιατί το ίδιο ερώτημα με Parameters και χωρίς φέρνει μία reader.HasRows false και true;</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/25335.aspx</link><pubDate>Thu, 22 Feb 2007 20:29:39 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:25335</guid><dc:creator>Νατάσα Μανουσοπούλου</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/25335.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=73&amp;PostID=25335</wfw:commentRss><description>&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="http://www.dotnetzone.gr/cs/Themes/default/images/icon-quote.gif"&gt; &lt;strong&gt;dtakis:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;p&gt;&lt;span style="font-weight:normal;font-size:11px;color:black;font-family:Courier New;background-color:transparent;"&gt;SqlCommand sqlCommandCheck &lt;span style="font-weight:normal;font-size:11px;color:red;font-family:Courier New;background-color:transparent;"&gt;=&lt;/span&gt; &lt;span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;"&gt;new&lt;/span&gt; SqlCommand(&lt;span style="font-weight:normal;font-size:11px;font-family:Courier New;"&gt;"SELECT * FROM users WHERE userid=@ParameterUserID AND name='@ParameterName' "&lt;/span&gt;, matchSqlConnection);&lt;/span&gt;&lt;br&gt;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/p&gt;&lt;p&gt;Βάζεις το όνομα της παραμέτρου σε ' ', δηλαδή ζητάς τους χρήστες που έχουν για όνομα '@ParameterName'. Αμφιβάλλω αν έχεις τέτοιο χρήστη &lt;img src="http://www.dotnetzone.gr/cs/emoticons/emotion-1.gif" alt="Smile" /&gt;&lt;br&gt;&lt;/p&gt;</description></item><item><title>Απ: Γιατί το ίδιο ερώτημα με Parameters και χωρίς φέρνει μία reader.HasRows false και true;</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/25333.aspx</link><pubDate>Thu, 22 Feb 2007 20:24:44 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:25333</guid><dc:creator>alexnir</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/25333.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=73&amp;PostID=25333</wfw:commentRss><description>&lt;P&gt;Οταν το πεδιο ειναι string (nvarchar) στο query πρεπει να περνας την τιμη μαζι με το (') μονο αυτακι στην αρχη και στο τελος.&lt;/P&gt;
&lt;P&gt;π.χ. select * from Table where Pedio = 'userID'&lt;/P&gt;
&lt;P&gt;αν η τιμη ειναι αριθμητικη (int) η τιμη πρεπει να περναει σκετη&lt;/P&gt;
&lt;P&gt;π.χ. select * from Table where Pedio = 9 &lt;/P&gt;
&lt;P&gt;ελπιζω να σε βοηθησα&lt;/P&gt;</description></item><item><title>Γιατί το ίδιο ερώτημα με Parameters και χωρίς φέρνει μία reader.HasRows false και true;</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/25332.aspx</link><pubDate>Thu, 22 Feb 2007 20:17:51 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:25332</guid><dc:creator>dtakis</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/25332.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=73&amp;PostID=25332</wfw:commentRss><description>&lt;P&gt;table: users&lt;/P&gt;
&lt;P&gt;userid: int&lt;/P&gt;
&lt;P&gt;name: varchar(10)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:black;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;SqlCommand sqlCommandCheck &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;new&lt;/SPAN&gt; SqlCommand(&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:#666666;FONT-FAMILY:Courier New;BACKGROUND-COLOR:#e4e4e4;"&gt;"SELECT * FROM users WHERE userid=@ParameterUserID AND name='@ParameterName' "&lt;/SPAN&gt;, matchSqlConnection);&lt;BR&gt;sqlCommandCheck.Parameters.AddWithValue(&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:#666666;FONT-FAMILY:Courier New;BACKGROUND-COLOR:#e4e4e4;"&gt;"@ParameterUserID"&lt;/SPAN&gt;, userid);&lt;BR&gt;sqlCommandCheck.Parameters.AddWithValue(&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:#666666;FONT-FAMILY:Courier New;BACKGROUND-COLOR:#e4e4e4;"&gt;"@ParameterName"&lt;/SPAN&gt;, name);&lt;BR&gt;&lt;BR&gt;SqlDataReader readerSql &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;=&lt;/SPAN&gt; sqlCommandCheck.ExecuteReader();&lt;BR&gt;&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;if&lt;/SPAN&gt; (!readerSql.HasRows) ...&lt;BR&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Εδώ παίρνω ότι ΔΕΝ έχει γραμμές ενώ έχει&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:black;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;SqlCommand sqlCommandCheck &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;new&lt;/SPAN&gt; SqlCommand(&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:#666666;FONT-FAMILY:Courier New;BACKGROUND-COLOR:#e4e4e4;"&gt;"SELECT * FROM users WHERE userid="&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;+&lt;/SPAN&gt; userid+ &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:#666666;FONT-FAMILY:Courier New;BACKGROUND-COLOR:#e4e4e4;"&gt;" AND name='"&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;+&lt;/SPAN&gt; name+ &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:#666666;FONT-FAMILY:Courier New;BACKGROUND-COLOR:#e4e4e4;"&gt;"' "&lt;/SPAN&gt;, matchSqlConnection);&lt;BR&gt;&lt;BR&gt;SqlDataReader readerSql &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;=&lt;/SPAN&gt; sqlCommandCheck.ExecuteReader();&lt;BR&gt;&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;if&lt;/SPAN&gt; (!readerSql.HasRows) ... &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Εδώ παίρνω ότι ΈΧΕΙ γραμμές (όπως και συμβαίνει)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Και έχω και ένα δεύτερο ερώτημα :&lt;/P&gt;
&lt;P&gt;Γιατί αν βάλω SELECT * FROM users WHERE userid='" + userid+ "' AND name='" + name+ "'&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Δηλαδή '' σε τιμή για int χτυπάει error για αδυναμία convertion σε int ή tinyint κτλ. Αφού το παραγόμενο ερώτημα αν το εκτελέσω στον SQL Server επιστρέφει κανονικά απάντηση.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Τι πρέπει να γνωρίζω για τον SQL Server &amp;amp; SQL και δεν το γνωρίζω;&amp;nbsp;&lt;/P&gt;</description></item></channel></rss>