1
我有一個提供AS400數據的web服務。 此web服務具有我想提出下面dynamic.See代碼一個固定的連接字符串:將連接對象傳遞給來自jQuery的ASP.Net webservice
使用Public Function GetData(sql As String) As DataTable
Dim _data As DataTable
Try
Dim s As String = "Provider=IBMDA400"
s &= ";Data Source=" & "x.x.x.x"
s &= ";User Id=" & "USER"
s &= ";Password=" & "PASS"
s &= ";Default Collection=" & "AAABBB"
con = New OleDbConnection(s)
Dim cmd As New OleDbCommand
With cmd
.Connection = con
.CommandType = CommandType.Text
.CommandText = sql
End With
Dim dap As New OleDbDataAdapter(cmd)
con.Open()
Dim dat As New DataSet
dap.Fill(dat)
con.Close()
con.Dispose()
_data = dat.Tables(0)
Catch ex As Exception
_data = New DataTable
End Try
Return _data
End Function
樣品web服務功能以上:
<WebMethod()> _
Public Function GetPicklistLines(picklist As String) As List(Of PicklistLine)
Dim lines As New List(Of PicklistLine)
Dim line As PicklistLine
sql = "select " & _
"OLPLNO,OLPLLI,OLORNO,OLLINE,OLPRDC,OLDESC,OLOQTS,OLCQTS,OLUNIT,OLORDS,PGDRNR, AAV01, AAV02, NAV03 " & _
"from SRBSOL " & _
"left outer join SRBPRG on PGPRDC=OLPRDC " & _
"left outer join Z2OOCFGF on F0ERNC=OLORNO and F0A2NB=OLLINE " & _
"where OLPLNO=" & picklist & " and OLSTAT <>' D'"
data = GetData(sql)
' TODO: insert ROW 0 to set active:
sql = "insert " & _
"into SRBSOL " & _
"(OLPLNO, OLPLLI) " & _
"values " & _
"(" & picklist & "," & 0 & ") " & _
"where OLPLNO=" & picklist & " and OLSTAT <>' D'"
For Each dr As DataRow In data.Rows
' TODO: get reported quantity:
sql = "select " & _
"RCBAQT " & _
"from Z2OOREXC " & _
"where RCPLNO='" & picklist & "' and RCPLLI='" & dr("OLPLLI") & "'"
line = New PicklistLine
With line
.PicklistNumber = picklist
.OrderNumber = IIf(TypeOf (dr("OLORNO")) Is DBNull, "", dr("OLORNO"))
.PicklistLinenumber = IIf(TypeOf (dr("OLPLLI")) Is DBNull, "", dr("OLPLLI"))
.Item = IIf(TypeOf (dr("OLPRDC")) Is DBNull, "", dr("OLPRDC"))
.ItemDescription = IIf(TypeOf (dr("OLDESC")) Is DBNull, "", dr("OLDESC"))
.InnerColor = IIf(TypeOf (dr("AAV01")) Is DBNull, "", dr("AAV01"))
.OuterColor = IIf(TypeOf (dr("AAV02")) Is DBNull, "", dr("AAV02"))
.Length = IIf(TypeOf (dr("NAV03")) Is DBNull, "", dr("NAV03"))
.Unit = IIf(TypeOf (dr("OLUNIT")) Is DBNull, "", dr("OLUNIT"))
.Quantity = IIf(TypeOf (dr("OLCQTS")) Is DBNull, "", CInt(dr("OLCQTS")))
.Needed = IIf(TypeOf (dr("OLOQTS")) Is DBNull, "", CInt(dr("OLOQTS")))
End With
lines.Add(line)
Next
Return lines
End Function
上述功能得到由jquery的調用:
function GetAllPicklists() {
$('#page_overview_search').addClass('ui-disabled');
$("#Picklists").html('');
//$("#MemberList").addClass("loading");
$.ajax({
type: "POST",
url: "http://" + host + "/services/picklists.asmx/GetAllPicklists",
data: "{'customer':'" + $('#select-customer').val() + "', 'route':'" + $('#select-route').val() + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnGetAllPicklistsSuccess,
error: OnError
});
}
我已經修改了Web服務功能提供JSON但是這是正在進行的工作... :)
一切工作正常,但我希望使連接字符串s 從GetData動態。我應該如何去設置與值(尚未確定)的連接對象數據源(IP),用戶ID,密碼和默認集合。 具體如何通過jquery POST 數據參數傳遞該連接對象和服務函數調用參數?將來可以在登錄時設置此連接對象嗎?
請隨時提出問題,以澄清你不清楚的事情。
在此先感謝!
您使用的是什麼版本的ASW? – SnakeDoc 2015-12-03 18:21:11
問題問2013,切換工作.. :) – grmbl 2015-12-04 09:18:49
我知道,你只是不經常碰到IBS客戶。 – SnakeDoc 2015-12-04 16:10:20