Advertisement
wingman007

ConnectionSQLServerCE

Nov 9th, 2014
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.35 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Data.SqlServerCe;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. namespace Connection2SQLCompactEditionConsole
  10. {
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             // SqlCeConnection
  16.             SqlCeConnection connection =
  17.             new SqlCeConnection(@"Data Source=c:\users\stoyan\documents\visual studio 2012\Projects\Connection2SQLCompactEditionWinForms\Connection2SQLCompactEditionWinForms\StoyanMS_SQL_CE.sdf;Password=password;Persist Security Info=True");
  18.             SqlCeCommand command = new SqlCeCommand("SELECT * FROM users", connection);
  19.             SqlCeDataAdapter dataAdapter = new SqlCeDataAdapter(command);
  20.             DataSet ds = new DataSet();
  21.             dataAdapter.Fill(ds);
  22.             Console.WriteLine("Done");
  23.             // while (aReader.Read())
  24.             // {
  25.             //    Console.WriteLine(aReader.GetInt32(0).ToString());
  26.             // }
  27.             // SqlCeDataReader aReader = command.ExecuteReader();
  28.             // while (aReader.Read())
  29.             // {
  30.             //    Console.WriteLine(aReader.GetInt32(0).ToString());
  31.             // }
  32.             // dataAdapter.
  33.             // Visualize DataSet.
  34.             Console.WriteLine(ds.GetXml());
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement