一个关于Delphi和Sql Server 6.5结合的Web编程问题

MikeZyx 2000-04-22 08:57:00
我是一个Web编程的初学者,在用Delphi进行ISAPI编程时,用本地数据库进行处理都没问题,但是当数据库用像SQL Server这样的远程数据库,常常出错,下面是我用来处理供应商查询的一段源程序,其功能是当用户在主页上输入供应商查询条件时,返回满足条件的数据记录:

unit UnitAll;

interface

uses
Windows, Messages, SysUtils, Classes, HTTPApp, DBWeb, Db, DBTables;

type
TWebModule1 = class(TWebModule)
Session1: TSession;
QrySaler: TQuery;
QueryTableProducer1: TQueryTableProducer;
QrySalerSalerNo: TStringField;
QrySalerSaler: TStringField;
QrySalerLinkMan: TStringField;
QrySalerPhone: TStringField;
QrySalerFax: TStringField;
QrySalerLxmanzw: TStringField;
procedure WebModule1dllSalerAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
procedure Session1Password(Sender: TObject; var Continue: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;

var
WebModule1: TWebModule1;

implementation

{$R *.DFM}

procedure TWebModule1.WebModule1dllSalerAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
With QueryTableProducer1 do
Begin
Caption:='供应商查询结果';
Header.Add('<html>');
Header.Add('<body>');
Footer.Add('</body>');
Footer.Add('</html>');
Query:=QrySaler;
Query.Open;
Response.Content:=Content;
Query.Close;
End;
end;

procedure TWebModule1.Session1Password(Sender: TObject;
var Continue: Boolean);
begin
Session1.AddPassword('111111');
Continue:=true;
end;

end.

前端主页文件:
<html>

<head>
<meta http-equiv="Content-Type"
content="text/html; charset=gb_2312-80">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<title>供应商资料查询</title>
</head>

<body bgcolor="#FCECF4">

<p align="center"><font color="#0000FF" size="5" face="隶书">供应商资料查询</font>
</p>

<hr width="90%">

<p align="center"> </p>

<p align="left">请输入查询条件:</p>

<form action="Http://bydsv03/scripts/PrjHeadLink.dll/Saler"
method="GET" name="form1">
<p align="center">供应商编码 <input type="text"
size="20" maxlength="6" name="Bh"> <br>
供应商名称 <input type="text" size="20" maxlength="22"
name="Name"> <br>
联 系 人 <input type="text" size="20" maxlength="10"
name="Man"> <br>
联系电话: <input type="text" size="20" name="Phone"> <br>
传  真: <input type="text" size="20" name="Fax"> </p>
<p align="center"><input type="submit" value="开始查询">
   <input type="reset" value="清除条件"> </p>
</form>

<p align="center"> </p>

<hr width="90%">

<p align="left"> </p>
</body>
</html>

运行后出现以下错误信息:
Internal Server Error 500

-------------------------------------------------------------------------
Exception: EDBEngineError
Message: Alias is not currently opened. [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed- User: _ Reason: Not defined as a valid user of a trusted SQL General SQL error. Server connection. Alias: BYDDB
我头都大了,请问哪位高手能帮我解决问题?
...全文
220 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
929 2000-04-25
  • 打赏
  • 举报
回复


IDC: Error Performing Query, Not Defined as a Valid User
Last reviewed: April 22, 1997
Article ID: Q149425

The information in this article applies to:
Microsoft Internet Information Server version 1.0


SYMPTOMS
When you access an IDC script, you may receive the following error message:


Error Performing Query
*[State=3700][Error=18450][Microsoft][ODBC SQL Driver][SQL Server]
Login failed- User: _ Reason: Not defined as a valid user of a
trusted SQL Server Connection.

CAUSE
The error message above may occur in the following conditions:

Your SQL Server is not the same computer as your Internet Information Server (IIS).
You are using Microsoft Windows NT Challenge/Response authentication on IIS.
You are using Integrated or Mixed Security on the Microsoft SQL Server.
You are not are not providing the Username: or Password: values in your IDC Script.

WORKAROUNDS
There are two possible workarounds:

Install SQL Server on the same computer as the Internet Information Server and set up your ODBC System DSN to be Local Server instead or a remote computer name.

-or-
Use Basic Authentication instead of Windows NT Challenge/Response (for example, the user will be prompted to login using a dialog box)

MORE INFORMATION
When the client executes the IDC script, IIS must determine whether the datasource is local or remote. If the datasource defined as Local System, the query is passed to the SQL Server on the same computer. If the datasource is remote, IIS must make a network connection to SQL Server. When it does, it does not pass the credentials of user logged on to the client computer; instead, it passes a blank username and password.

The SQL Server tries to validate a user without a username; it fails, and it returns the following message to IIS:


Login failed- User: _ Reason: Not defined as a
valid user of a trusted SQL Server Connection

The Internet Information Server then passes the results of the query to the client web browser.



--------------------------------------------------------------------------------

Additional query words: prodiis winnt
Keywords : iishowto kbnetwork
Version : 1.0 3.51
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 22, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.

basic authentication

A security mechanism using a standard HTTP mechanism in which user information is sent received as clear text. (The term clear text indicates data is transmitted as clearly readable text characters rather than binary bit-streamed information, which is not text-formatted.) Passwords and user names are encoded but not encrypted in this type of authentication.

challenge/response authentication

A security mechanism in which a client computer uses its established user logon information to identify itself to the server computer. The user is not prompted to enter these user credentials. Instead, the information is available after the user first logs on to a Microsoft® Windows NT®-based computer.


上面这段文字是由MSDN中摘录的。
错误产生原因:IIS在执行数据库连接时要进行用户的登录,这在SQL SERVER与IIS同一机上时很容易做到,但当不在同一机而要登录到另一台机器上时会由于找不到用户登录信息出错。
解决方法:把IIS和SQL SERVER放在一台机器上或修改SQL SERVER的安全验证方式为basic authentication,比如说提示输入用户名和密码再进行登录或在程序以预定用户名登录。
第1章 窗体与界面设计 1 1.1 菜单应用 2 实例001 在系统菜单中添加菜单项 2 实例002 带历史信息的菜单 3 实例003 菜单动态合并 4 实例004 像“开始”菜单一样漂亮的菜单 5 实例005 多彩的菜单 6 实例006 可以拉伸的菜单界面 8 1.2 工具栏设计 9 实例007 带背景的工具栏 9 实例008 浮动工具栏 10 1.3 状态栏设计 11 实例009 在状态栏中显示检查框 11 实例010 带进度条的状态栏 12 实例011 状态栏中加入图标 13 1.4 导航菜单界面 14 实例012 OutLook界面 14 实例013 带导航菜单的主界面 15 实例014 图形化的导航界面 16 1.5 特色程序界面 18 实例015 类QQ的程序界面 18 实例016 类似Windows XP的程序界面 20 实例017 以图形按钮显示的界面 21 实例018 以树型显示的程序界面 23 实例019 以XPManifest组件显示界面 24 实例020 动态按钮的窗体界面 25 1.6 特殊形状的窗体 26 实例021 非矩形窗体 26 实例022 建立字体形状窗体 28 1.7 多媒体光盘 29 实例023 自动启动的多媒体光盘程序 29 实例024 为触摸屏程序添加虚拟键盘 30 实例025 触摸屏系统 31 1.8 窗体效果 33 实例026 半透明渐显窗体 33 实例027 窗口颜色的渐变 34 实例028 带背景的窗体 35 实例029 为窗体增加边框 36 1.9 窗体动画 37 实例030 窗体中的滚动字幕 37 实例031 动画显示窗体 38 实例032 制作闪烁的窗体 39 实例033 直接在窗体上绘图 40 实例034 动画形式的程序界面 41 实例035 以时钟显示界面窗体 42 1.10 标题栏窗体 44 实例036 标题栏上的按钮 45 实例037 使窗体标题栏文字右对齐 47 实例038 没有标题栏但可以改变大小的窗口 48 1.11 设置窗体位置 49 实例039 不可移动的窗体 49 实例040 设置窗体在屏幕中的位置 50 实例041 始终在最上面的窗体 51 1.12 设置窗体大小 52 实例042 限制窗体大小 52 实例043 获取桌面大小 53 实例044 组件大小随窗体的改变而改变 53 实例045 在窗口间移动按钮 54 实例046 如何实现Office助手 55 1.13 窗体控制技术 56 实例047 在关闭窗口前加入确认对话框 56 实例048 程序在循环中响应界面操作 57 实例049 使用任意组件拖动窗体 58 实例050 动态创建窗体和释放窗体 59 实例051 修改提示字体及颜色 60 1.14 其他技术 61 实例052 窗口融合技术 61 实例053 给MDI窗体加背景 62 实例054 如何关闭MDI类型窗体中的子窗体 63 实例055 向提示框中添加图标 64 第2章 控件应用 67 2.1 TEdit控件应用典型实例 68 实例056 从右至左输入数据 68 实例057 为TEdit控件添加列表选择框 69 实例058 只允许输入数字的TEdit组件 70 2.2 TSpeedButton控件应用典型实例 71 实例059 在TSpeedButton按钮中显示图标 71 实例060 折行显示按钮标题 72 2.3 TMemo控件应用典型实例 73 实例061 设置TMemo组件的边界 73 实例062 TMemo组件的光标定位 74 实例063 得到TMemo中的可见行数 75 2.4 TListBox控件应用典型实例 76 实例064 在TListBox组件间交换数据 76 实例065 为TListBox添加水平滚动条 77 实例066 将数据库数据添加到组合框中 78 实例067 借助绑定控件实现数据选择录入 79 2.5 TListView控件应用典型实例 80 实例068 TListView列表拒绝添加重复信息 80 实例069 将数据库数据添加到TListView控件 82 实例070 用TListView控件制作导航界面 83 实例071 在TListView控件中对数据排序或统计 84 实例072 在TListView组件中绘制底纹 86 实例073 在列表视图中拖动视图项 87 2.6 TTreeView控件应用典型实例 88 实例074 将数据库数据显示到树视图中 88 实例075 用TTreeView控件制作导航界面 90 实例076 TTreeView组件遍历磁盘目录 91 实例077 TTreeView组件在数据库中的应用 92 2.7 TStringGrid控件应用典型实例 94 实例078 程序运行时对

5,386

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧