返回首页

您好
我对C#Windows应用工作,在打印按钮,如果我点击打印按钮,打印机的路径,在ini文件,当我试图运行显示错误
下面我米代码

           private void btnPrinter_Click(object sender, EventArgs e)

           {

            private printcon pObj = new printcon() //Here "printcon" is a class file//

            private OdbcConnection connPrt = new OdbcConnection();

            connPrt = new OdbcConnection(pObj.connection());   //Format of the        initialization string does not conform to specification starting at index 0.//

            PrintDocument doc = new PrintDocument();

            doc.PrinterSettings.PrinterName = Convert.ToString(connPrt);

            doc.PrintPage += this.doc_PrintPage;

            PrintDialog dlgSettings = new PrintDialog();

            dlgSettings.Document = doc;

            doc.Print();   

           }
如果可能的话,请帮助

感谢问候
indrajit达斯古普塔

回答

评论会员:游客 时间:2012/02/06
OriginalGriff:我们不能从该代码HEP:{C}我们不知道什么printcon.connection是作为一个连接字符串返回-你还没有表现出我们。那就是ODBC系统抱怨什么。在调试器中运行你的程序。放在一个断点"connPrt=新的OdbcConnection......"线,到pObj.connection方法和步骤。工作从那里出了什么问题,你应该能够
帕瓦尔Anuja多尔:请参考这篇文章,可能有助于
]
评论会员:sandesh.mumbai 时间:2012/02/06
您的通话到printcon()创建对象,而返回错误的值可能是因为使用pobj指向下不下降OdbcConnection对象,请把在实例printcon放断点,你呼叫,见返回值类型
NBSP

私人printcon pobj指向=新printcon()/ /这里的"printcon"是一个类文件/ /
/ / /把上面的行上的断点,然后为价值CHK。类型
NBSP

NBSP connPrt私人的OdbcConnection =新的OdbcConnection()
NBSP connPrt =新的OdbcConnection(pObj.connection());