A union of curiosity and data science

Knowledgebase and brain dump of a database engineer

C# Loop through sql server database recordset with SqlClient

Code : 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;

namespace MyNamespace
    class Program
            static void Main(string[] args) {

            string connetionString = "Data Source=<servername>;Initial Catalog=<database>;User ID=<user_id>;Password=<password>";
            SqlConnection connection = new SqlConnection(connetionString);

            string sql = "select top 10 * from information_schema.tables";

            SqlCommand command = new SqlCommand(sql, connection);
            command.CommandTimeout = 600;
            SqlDataReader dataReader = command.ExecuteReader();

            while (dataReader.Read())


Comments (1) -

  • QVRcgIuo

    12/9/2021 12:45:55 AM | Reply

    353124 297519The vacation trades offered are evaluated a variety of in the chosen and merely great value all around the world. Those hostels are normally based towards households which you�ll discover accented via charming shores promoting crystal-clear fishing holes, concurrent of one�s Ocean. Hotels Discounts 473606

Add comment