Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Data.OleDb;
- using System.Data.Odbc;
- using System.Data.SqlClient;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Start!");
- OdbcConnection myConnection = new OdbcConnection("Driver={mySQL};Server=192.168.1.110;Option=16834;Database=MYDB;User=mydb;Password=mydb;");
- Console.WriteLine("Start2!");
- try
- {
- myConnection.Open();
- Console.WriteLine("Start3!");
- }
- catch (Exception e)
- {
- Console.WriteLine(e.ToString());
- }
- try
- {
- OdbcCommand myCommand = new OdbcCommand("Select * from mytable", myConnection);
- OdbcDataReader myReader = myCommand.ExecuteReader();
- Console.Write("Here\n");
- while (myReader.Read())
- {
- for (int i = 0; i < myReader.FieldCount; i++)
- {
- Console.Write(myReader[i] + " ");
- }
- Console.Write("\n");
- }
- }
- catch (Exception e)
- {
- Console.WriteLine(e.ToString());
- }
- myConnection.Close();
- while (true)
- {
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement