1.当然不用写4个,具体就看你怎么做了
2.这是以前一个网友提供的,我还没来得及验证,你可以参考一下:你先在VS。NET中做一个WEB SERVICE,如:CustomerCodeService.asmx
------------------------------------------------------
<%@ WebService Language="vb" Codebehind="CustomerCodeService.asmx.vb" Class="CustomerCodeService" %>
CustomerCodeService.asmx.vb
------------------------------------------------------
Imports System.Web.Services
Imports System.Xml.Serialization
Public Class CustomerCodeInfo
<XmlElement()> _
Public CodeIsValid As Boolean
<XmlElement()> _
Public ID As String
<XmlElement()> _
Public Name As String
<XmlElement()> _
Public Currency As String
End Class
<WebService(Namespace:="http://dotAge.com/")> _
Public Class CustomerCodeService
Inherits System.Web.Services.WebService
#Region " Web Services Designer Generated Code "
Public Sub New()
MyBase.New()
'This call is required by the Web Services Designer.
InitializeComponent()
'Add your own initialization code after the InitializeComponent() call
End Sub
'Required by the Web Services Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Web Services Designer
'It can be modified using the Web Services Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
components = New System.ComponentModel.Container()
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
'CODEGEN: This procedure is required by the Web Services Designer
'Do not modify it using the code editor.
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
#End Region
<WebMethod()> Public Function GetCustomerCodeInfo(ByVal CustomerCode As String) As CustomerCodeInfo
Dim C As New DataAccess.Customer()
GetCustomerCodeInfo = New CustomerCodeInfo()
If C.GetInfo(CustomerCode) Then
GetCustomerCodeInfo.CodeIsValid = True
GetCustomerCodeInfo.ID = Trim(C.Code)
GetCustomerCodeInfo.Name = Trim(C.Name)
GetCustomerCodeInfo.Currency = Trim(C.Currency)
Else
GetCustomerCodeInfo.CodeIsValid = False
End If
C = Nothing
End Function
End Class
然后在页面的写如下客户端脚本,就可以不刷新得到客户的几个属性填写以FORM中的控件中
<script language=javascript>
var objXMLDoc = new ActiveXObject("Microsoft.XMLDOM");
objXMLDoc.async = false;
objXMLDoc.load( "CustomerCodeService.asmx/GetCustomerCodeInfo?CustomerCode=" + escape(f.value));
CodeIsValid = objXMLDoc.selectSingleNode("//CustomerCodeInfo/CodeIsValid") ;
if (CodeIsValid.text=="true") {
frmID.value = objXMLDoc.selectSingleNode("//CustomerCodeInfo/ID").text ;
frmName.value = objXMLDoc.selectSingleNode("//CustomerCodeInfo/Name").text ;
frmCurrency.value = objXMLDoc.selectSingleNode("//CustomerCodeInfo/Currency").text ;
} else {
alert("Customer code is invalid !") ;
}
</script>
以上frmID, frmName, frmCurrency 都是FORM中的INPUT TYPE=TEXT
2.这是以前一个网友提供的,我还没来得及验证,你可以参考一下:你先在VS。NET中做一个WEB SERVICE,如:CustomerCodeService.asmx
------------------------------------------------------
<%@ WebService Language="vb" Codebehind="CustomerCodeService.asmx.vb" Class="CustomerCodeService" %>
CustomerCodeService.asmx.vb
------------------------------------------------------
Imports System.Web.Services
Imports System.Xml.Serialization
Public Class CustomerCodeInfo
<XmlElement()> _
Public CodeIsValid As Boolean
<XmlElement()> _
Public ID As String
<XmlElement()> _
Public Name As String
<XmlElement()> _
Public Currency As String
End Class
<WebService(Namespace:="http://dotAge.com/")> _
Public Class CustomerCodeService
Inherits System.Web.Services.WebService
#Region " Web Services Designer Generated Code "
Public Sub New()
MyBase.New()
'This call is required by the Web Services Designer.
InitializeComponent()
'Add your own initialization code after the InitializeComponent() call
End Sub
'Required by the Web Services Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Web Services Designer
'It can be modified using the Web Services Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
components = New System.ComponentModel.Container()
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
'CODEGEN: This procedure is required by the Web Services Designer
'Do not modify it using the code editor.
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
#End Region
<WebMethod()> Public Function GetCustomerCodeInfo(ByVal CustomerCode As String) As CustomerCodeInfo
Dim C As New DataAccess.Customer()
GetCustomerCodeInfo = New CustomerCodeInfo()
If C.GetInfo(CustomerCode) Then
GetCustomerCodeInfo.CodeIsValid = True
GetCustomerCodeInfo.ID = Trim(C.Code)
GetCustomerCodeInfo.Name = Trim(C.Name)
GetCustomerCodeInfo.Currency = Trim(C.Currency)
Else
GetCustomerCodeInfo.CodeIsValid = False
End If
C = Nothing
End Function
End Class
然后在页面的写如下客户端脚本,就可以不刷新得到客户的几个属性填写以FORM中的控件中
<script language=javascript>
var objXMLDoc = new ActiveXObject("Microsoft.XMLDOM");
objXMLDoc.async = false;
objXMLDoc.load( "CustomerCodeService.asmx/GetCustomerCodeInfo?CustomerCode=" + escape(f.value));
CodeIsValid = objXMLDoc.selectSingleNode("//CustomerCodeInfo/CodeIsValid") ;
if (CodeIsValid.text=="true") {
frmID.value = objXMLDoc.selectSingleNode("//CustomerCodeInfo/ID").text ;
frmName.value = objXMLDoc.selectSingleNode("//CustomerCodeInfo/Name").text ;
frmCurrency.value = objXMLDoc.selectSingleNode("//CustomerCodeInfo/Currency").text ;
} else {
alert("Customer code is invalid !") ;
}
</script>
以上frmID, frmName, frmCurrency 都是FORM中的INPUT TYPE=TEXT
<appSettings>
<add key="DBConnectionString1" value="server=localhost;uid=sa;pwd=yourpw;database=db1" />
<add key="DBConnectionString2" value="server=localhost;uid=sa;pwd=yourpw;database=db2" /><add key="DBConnectionString3" value="server=localhost;uid=sa;pwd=yourpw;database=db3" /><add key="DBConnectionString4" value="server=localhost;uid=sa;pwd=yourpw;database=db4" /> </appSettings>
在aspx里要使用数据库连接的地方加入
dim sqlcon as new sqlconnection(DBConnectionString1) 就是连接db1,依此类推
<appSettings> <add key="DBConnectionString1" value="server=local;uid=username;pwd=password;database=yourdb1" />
<add key="DBConnectionString2" value="server=local;uid=username;pwd=password;database=yourdb2" />
<add key="DBConnectionString3" value="server=local;uid=username;pwd=password;database=yourdb3" />
<add key="DBConnectionString4" value="server=local;uid=username;pwd=password;database=yourdb4" />
</appSettings>
里面一共四个<add />每一个换成你连接数据库的连接字段在aspx页面里面
在<script language="vb" runat=server>前面
page_load前面
加上Dim DBConnectionString1 As String = ConfigurationSettings.AppSettings("DBConnectionString1")
Dim DBConnectionString2 As String = ConfigurationSettings.AppSettings("DBConnectionString2")
Dim DBConnectionString3 As String = ConfigurationSettings.AppSettings("DBConnectionString3")
Dim DBConnectionString4 As String = ConfigurationSettings.AppSettings("DBConnectionString4")依次为你连接四个数据库的连接字段
在程序当中每次需要写连接到数据库的字段的时候
就用DBConnectionString1 2 3 4 代替
第二个问题我不会
他的数据库经常刷新,不知道这样行吗?
我觉得不需要考虑数据库刷新的问题,我只想实现网页上的数据间隔两秒就自动的更新一次.但必须要无刷新,就像我们在网上聊天室聊天一样!
TO;terryxin(有聊的冬季)
框架结构是肯定不行的
TO;kld3000(汪洋)
感谢您给我这个提示,但是我问的意思是说如何将4个大体相同的东西,写成个类!
SQL SERVER2000 数据视图,只要数据结构不常改动,这是一个好方案
第二个不会!
XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
XmlHttp.open("POST", "你的WebService",false);
XmlHttp.Send()
xmlDoc = new ActiveXObject('Microsoft.XMLDOM')
xmlDoc.async = false;
xmlDoc.load(XmlHttp.responseXML);
GetValue(xmlDoc);3.查找节点建立表格。。function GetValue(xmlDoc)
{
var ID;
ID = xmlDoc.documentElement.selectNodes("//ID");
numRow=ID.length;
。。
其它各个节点将值付给数组。。
。。
initTable(numRow,numCell); 。。行列数生成表格
AddItem();。。添加数据。。}function initTable(nRow,nCell)
{
根据行列数生成表格。。
}function AddItem()
{
给表格付值
}4.根据下面的循环调用就可以了。。
function LoopExecuteWs()
{
XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
XmlHttp.open("POST", "你的WebService",false);
XmlHttp.Send()
xmlDoc = new ActiveXObject('Microsoft.XMLDOM')
xmlDoc.async = false;
xmlDoc.load(XmlHttp.responseXML)
GetValue(xmlDoc);
setTimeout("LoopExecuteWs()",1000);
}