2012-01-01 2 views
0

분명히 Transoft 드라이버 인 DSN에서 테이블 이름을 연결하고 가져 오는 것에 대한 질문이 있습니다. 이 질문은 여기에 있습니다 : 나는 모든 테이블 이름을 표시 할 수있는 일이 대답 한 후Transoft ODBC sqlReader 오류 : 파일이 존재하지 않습니다 : TableName

OdbcConnection.GetSchema("TABLES"); not working

. 이제 나는 그 테이블을 읽는 것이 여전히 잘 작동하지 않는다는 것을 알았다. APPT가 읽은 TABLENAME이

Failed to connect to data source: ERROR [HY000][Transoft][TSODBC][usqlsd](log: 5852-142748) File does not exist: APPT

: 오류가 발생합니다.

void dumbRead(String tableName) 
    { 
     OdbcCommand sqlCommand = conn.CreateCommand(); 
     // execute sql 
     sqlCommand.CommandText = 
     "select * from " + tableName; //I even tried with qualifying table name like: 
     // "select * from douglas." + tableName; where the douglas. is the account i.e. 
     // the table owner I think. 
     OdbcDataReader sqlReader = sqlCommand.ExecuteReader(); 
     int fieldCount = sqlReader.FieldCount; 
     MessageBox.Show("Field Count: " + fieldCount); 
    } 

그러나 그것은 나의 선택 * 문을 좋아하지 않는 어떤 이유로 원인을 작동하지 않습니다 : 그것은 지금은 간단한 코드입니다. 위에서 설명한 오류가 발생합니다. Transoft USQL은 정말 다른 짐승입니까?

다른 모든 것 (지금까지 내가 답변을 얻은 마지막 게시물에 다시 감사드립니다)은 훌륭하게 작동합니다. 여기

는 의견에 따라 내 연결 문자열입니다

private void Form1_Load(object sender, EventArgs e) 
    { 
     txtDSNName.Text = "Company_Shared"; 
    } 

    private void btnConnect_Click(object sender, EventArgs e) 
    { 
     ConnectToData(txtDSNName.Text); 
    } 
    public void ConnectToData(String dsn) 
    { 

     conn= new System.Data.Odbc.OdbcConnection(); 

     //conn.ConnectionString = "FIL=MS Access;DSN=" + dsn; 
     conn.ConnectionString = "DSN=" + dsn; //dsn equals "Company_Shared" 
     try 
     { 
      conn.Open(); 
      MessageBox.Show("Connected!"); 
+0

데이터베이스 관리 도구에서'SELECT * FROM APPT'을 (를) 실행하면 어떻게됩니까? –

+0

클라이언트 컴퓨터에 원격으로 연결하려고하고 관리자 도구가 없습니다. 그것은 의사 사무실이고 그는 자신의 데이터베이스에서 데이터를 가져 오기를 원합니다. 이것은 할 일이었습니다. 그래서 거기에 관리자 권한을 설치하지 않아도 무료로 다운로드 할 수있는 쿼리 데이터베이스 관리 도구가 무엇입니까? – Codejoy

+0

실행중인 DBMS는 무엇입니까? –

답변

0

하여 필요한 ODBC의 commad를 구축하기 위해이 같은 간단한 구조를 사용하여 시도 및 연결은 여기 객체 그냥 간단하게 삽입

테스트 한 예이다
 OdbcConnection odbcConn = new OdbcConnection(odbcConnString);//your odbc conn String 
     odbcConn.Open(); 
     OdbcTransaction odbcTransStockList;//if you want to use transaction 
     using (OdbcCommand odbcmdSelect = new OdbcCommand(strInsertStringAccess, odbcConn))//or if you are using SQL Server I am assuming it's Access 
     { 
      odbcmdInsert.CommandTimeout = 60; 
      odbcTransStockList = odbcConn.BeginTransaction(); 
      odbcmdInsert.Transaction = odbcTransStockList; 
      odbcmdInsert.CommandType = System.Data.CommandType.Text; 
      try 
      { 
       odbcmdInsert.ExecuteNonQuery(); 
       odbcTransStockList.Commit(); 
      } 
      catch (OdbcException odbcEx) 
      { 
       Console.WriteLine(odbcEx.Message); 

      } 
     } 
     ((IDisposable)odbcTransStockList).Dispose(); 
     ((IDisposable)odbcConn).Dispose(); 
    } 
    catch (OdbcException odbcEx) 
    { 
     Console.WriteLine(odbcEx.Message); 
    }