VB.NET中怎么連接SAP,很多新手對(duì)此不是很清楚,為了幫助大家解決這個(gè)難題,下面小編將為大家詳細(xì)講解,有這方面需求的人可以來(lái)學(xué)習(xí)下,希望你能有所收獲。

成都創(chuàng)新互聯(lián)公司堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:網(wǎng)站制作、成都網(wǎng)站設(shè)計(jì)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的扎賚諾爾網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!
以下見代碼示例:
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports System.Data.OleDb
Imports System.Xml
Public Class SAPConn
Public oFunction As Object ' SAP Functions
Public oConnection As Object ' SAP oConnection
Dim cmd As OleDbCommand
Dim SqlAd As OleDbDataAdapter
Dim sql As String
'測(cè)試連接的代碼
Private Sub BtnConnn_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs)
Handles BtnConnn.Click
Try
oFunction = CreateObject("SAP.Functions.unicode")
oConnection = oFunction.Connection
oConnection.User = "CRMDEV69"
oConnection.Password = "654321"
oConnection.System = "CD2"
oConnection.ApplicationServer = "172.18.95.173"
oConnection.SystemNumber = 7
oConnection.Client = "164"
oConnection.Language = "ZH"
If oConnection.Logon(0, True) = True Then
MsgBox("連接成功!")
Else
MsgBox("連接失敗!")
End If
Catch ex As Exception
MsgBox(ex.ToString(), MsgBoxStyle.Information, "提示")
Return
End Try
End Sub
Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
Dim GetCustomers As Object
Dim Customers As Object
Dim i As Integer
Dim sqlstr As String = ""
' 通過(guò)RFC接口遠(yuǎn)程運(yùn)行SAP內(nèi)部函數(shù)ZCSMS_GET_HRINFO
' 賦要調(diào)用的SAP內(nèi)建函數(shù)名
Try
GetCustomers = oFunction.Add("ZCSMS_GET_HRINFO")
'設(shè)置輸入?yún)?shù)并賦值
GetCustomers.Exports("BEGDAFROM") = ""
GetCustomers.Exports("BEGDATO") = ""
GetCustomers.Exports("MILL") = "7960"
GetCustomers.Exports("NUMBERFROM") = "0061500001"
GetCustomers.Exports("NUMBERTO") = "0061500200"
Customers = GetCustomers.Tables("THR")
If GetCustomers.Call Then
'循環(huán)插入到數(shù)據(jù)庫(kù)表中
For i = 1 To Customers.RowCount
sqlstr = "Insert into ghy_employee(MILL,
PERNR, NAME1, STEXT) values ('" & Customers
(i, "MILL") & "','" & Customers(i, "PERNR")
& "','" & Customers(i, "NAME1") & "','"
& Customers(i, "STEXT") & "' )"
Config.ExecAccess(sqlstr)
Next i
MsgBox("獲取數(shù)據(jù)成功")
Else
MsgBox(" 搜索出錯(cuò)! 出錯(cuò)信息: " +
GetCustomers.exception)
End If
Catch ex As Exception
MsgBox(ex.ToString)
Return
End Try
End Sub
'通過(guò)GridView顯示數(shù)據(jù)
Private Sub Button2_Click(ByVal sender As System.
Object, ByVal e As System.EventArgs) Handles
Button2.Click
sql = "select * from ghy_employee "
SqlAd = New OleDbDataAdapter(sql, oConn)
DS.Clear()
If DS.Tables.Contains("ghy_employee") Then
DS.Tables.Remove("ghy_employee")
End If
SqlAd.Fill(DS, "ghy_employee")
DvInvoice.DataSource = DS.Tables("ghy_employee").
DefaultView
DvInvoice.Refresh()
DvInvoice.ClearSelection()
DvInvoice.Columns("MILL").HeaderText = "工廠"
DvInvoice.Columns("PERNR").HeaderText = "員工編號(hào)"
DvInvoice.Columns("NAME1").HeaderText = "員工姓名"
DvInvoice.Columns("STEXT").HeaderText = "員工部門"
End Sub
End Class
看完上述內(nèi)容是否對(duì)您有幫助呢?如果還想對(duì)相關(guān)知識(shí)有進(jìn)一步的了解或閱讀更多相關(guān)文章,請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝您對(duì)創(chuàng)新互聯(lián)的支持。
網(wǎng)站名稱:VB.NET中怎么連接SAP
文章網(wǎng)址:http://chinadenli.net/article44/jijshe.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)公司、網(wǎng)站改版、微信小程序、建站公司、網(wǎng)站營(yíng)銷、網(wǎng)站內(nèi)鏈
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)