Windows User Control 在 Web上的应用(姑且说是)上的问题?
为什么ActiveX.net(看源代码)访问的数据库是客户端的
C:\Documents and Settings\Administrator\桌面\db.mdb
而不是我指定的客户端数据库(看源代码)
C:\Inetpub\wwwroot\control\db.mdb
,并且运行时以上这两个文件都要在(更想不通).
特别特别想让微软全球技术中心帮我回答!
顺便问另一个相关的问题,如果ActiveX.net控件调用客户端的DLL,而这个DLL又访问客户端文件或数据库,这个DLL用相对地址的话,数据库应该在什么位置。这个DLL用绝对地址的话,有没有上面的相似的问题
namespace Lpzwork.HelloWorldControl {
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Data;
using System.Data.OleDb;
using System.Xml;
public class HelloWorldControl : System.Windows.Forms.Control
{
protected override void OnPaint(PaintEventArgs e)
{
string name=Text;
new OleDbPermission(PermissionState.Unrestricted).Assert();
e.Graphics.DrawString("hello "+name+"! your password is "+GetPass(name),
Font,
new SolidBrush(ForeColor),
xPos, yPos);
CodeAccessPermission.RevertAssert();
}
public string GetPass(string name)
{
string msg;
new FileIOPermission(PermissionState.Unrestricted).Assert();
OleDbConnection OleDbConnection1=new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=C:\\Inetpub\\wwwroot\\control\\db.mdb;Persist Security Info=False");
OleDbDataAdapter OleDbDataAdapter1=new OleDbDataAdapter("SELECT * FROM db.user where name='"+name+"'",OleDbConnection1);
DataSet ds = new DataSet();
OleDbDataAdapter1.Fill(ds, "user");
if(ds.Tables[0].Rows.Count!=0)
{
msg = ds.Tables[0].Rows[0][1].ToString();
}
else
{
msg="";
}
CodeAccessPermission.RevertAssert();
return msg;
}
}
我的调用页面
<html>
<script>
function ChangeText() {
simpleControl1.Text = text1.value;
}
</script>
<body>
<p>Simple Control
<br>
<br>
</body>
<object id="simpleControl1"
classid="SimpleControl.dll#Microsoft.Samples.WinForms.Cs.SimpleControl.SimpleControl"
height="300" width="600" VIEWASTEXT>
<param name="Text" value="lpz">
</object>
<br>
<br>
<input type="text" id="text1">
<input type="button" value="Change Text" onclick="ChangeText()">
</html>