經(jīng)過一個(gè)星期的學(xué)習(xí),現(xiàn)將自己學(xué)習(xí)的心得和大家交流一下吧!
Sybase 12.5用Ado.Net訪問總結(jié) Sybase 12.5—ODBC驅(qū)動(dòng)訪問數(shù)據(jù)庫:出現(xiàn)亂碼。 Sybase 12.5—OLEDB驅(qū)動(dòng)訪問數(shù)據(jù)庫:出現(xiàn)亂碼。 Sybase 12.5—ODBC驅(qū)動(dòng)訪問數(shù)據(jù)庫: 改變字符編碼:iso_1改為:cp850 出現(xiàn)亂碼出時(shí)Sybase 12.5 —Sql工具顯示亂碼 Sybase 12.5—OLEDB驅(qū)動(dòng)訪問數(shù)據(jù)庫: 改變字符編碼:iso_1改為:cp850 出現(xiàn)亂碼出時(shí)Sybase 12.5 —Sql工具顯示亂碼 Sybase 12.5—Sybase System 11驅(qū)動(dòng)訪問數(shù)據(jù)庫:用ODBC訪問數(shù)據(jù)庫不會(huì)出現(xiàn)亂碼。 代碼: private void Button1_Click(object sender, System.EventArgs e) { string StrCon="Driver={Sybase System 11};Srvr=server;database=Tax;uid=sa;pwd=;"; OdbcConnection Conn=new OdbcConnection(StrCon); OdbcDataAdapter Adapter=new OdbcDataAdapter("select * from BM_SZ where SZBM=‘" + this.TextBox2.Text + "‘",Conn); DataSet Set=new DataSet(); Adapter.Fill(Set); this.DataGrid1.DataSource=Set; this.DataGrid1.DataBind(); } //調(diào)用Sybase存儲(chǔ)過程 private void Button2_Click(object sender, System.EventArgs e) { try { string StrCon="Driver={Sybase System 11};Srvr=server;database=Tax;uid=sa;pwd=;"; OdbcConnection Conn=new OdbcConnection(StrCon); Conn.Open(); OdbcParameter Parameter; OdbcCommand Comm=new OdbcCommand("{ CALL test(?) }",Conn); Comm.CommandType=CommandType.StoredProcedure; Parameter=Comm.Parameters.Add("@b",OdbcType.VarChar,10); Parameter.Direction=ParameterDirection.Input; Parameter.Value=this.TextBox1.Text; OdbcDataReader Reader=Comm.ExecuteReader(); this.DataGrid1.DataSource=Reader; this.DataGrid1 .DataBind(); } catch(Exception Err) { Response.Write(Err.Message); } } 1樓 那要是sybase11那,怎么通過ado.net或者oledb連接那? 2樓 OdbcConnection 就可以阿,要不然你用12.5的驅(qū)動(dòng)程也是可以的,我以前就用過 3樓 gz 4樓 那用OdbcConnection連接sybase 12.5的時(shí)候該用什么連接字符串??用Driver={SYBASE ASE ODBC Driver};Srvr=server;database=Tax;uid=sa;pwd=;會(huì)出亂碼!連接字符串中添加charset=iso_1后倒是不會(huì)出現(xiàn)亂碼問題,但是在傳中文的時(shí)候會(huì)報(bào)錯(cuò)!類似于這條語句:OdbcDataAdapter Adapter=new OdbcDataAdapter("select * from BM_SZ where SZBM=‘" + this.TextBox2.Text + "‘",Conn);其中this.TextBox2.Text是中文,它會(huì)報(bào)錯(cuò):when String data Translation data trunctation" |
|