问题描述
[WebMethod]publicDataSetSQLDB(stringQuery){SqlConnectionCS=newSqlConnection("server=CHINA-58E53D04C;Trusted_Connection=yes;database="+this.Server.MapPath("test"));SqlDataAdaptermyCommand=newSqlDataAdapter(Query,CS);DataSetmyDataSet=newDataSet();myCommand.Fill(myDataSet,"Results");returnmyDataSet;}[WebMethod]publicDataSetAccessDB(stringQuery){stringstrAccessConn="Provider=Microsoft.Jet.OLEDB.4.0;DataSource="+this.Server.MapPath("db2.mdb");OleDbConnectionmyAccessConn=newOleDbConnection(strAccessConn);OleDbCommandmyAccessCommand=newOleDbCommand(Query,myAccessConn);OleDbDataAdaptermyDataAdapter=newOleDbDataAdapter(myAccessCommand);myAccessConn.Open();DataSetmyDataSet=newDataSet();myDataAdapter.Fill(myDataSet,"Results");myAccessConn.Close();returnmyDataSet;}这里面DataSource及database的写法,可不可以又个正则表示之类的东西,自己会找到数据库。比如我放进去db.mdb,不需要知道名字就连接上去因为webservice生成DLL后看不见源码,如果随意放入数据库,数据库的名字怎么解决??