Beruflich Dokumente
Kultur Dokumente
Right click on all reference file, goto properties and set copy property to true
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Configuration;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SAP.Middleware.Connector;
using System.Data.SqlClient;
namespace SAP_Customers1
{
public Transfer()
InitializeComponent();
SqlConnection con;
SqlCommand cmd;
SqlDataAdapter da;
this.Lbl_Clr();
btnlog.Focus();
grvtab.Visible = true;
txtreader.Visible = false;
this.Lbl_Clr();
RfcDestination mydestination;
RfcRepository myrepository;
try
con.Close();
con.Open();
mydestination = RfcDestinationManager.GetDestination("NCO_TESTS");
myrepository = mydestination.Repository;
this.Lbl_Clr();
lblctn.Text = ex.Message.ToString();
txtreader.Text = ex.Message.ToString();
txtreader.Visible = true;
grvtab.Visible = false;
return;
try
bapidolist.Invoke(mydestination);
if (dotable.RowCount > 0)
lblfechdata.Text = DateTime.Now + " : Featch " + dotable.RowCount + " Records From sap do
table";
if (dotable.ElementAt(i).GetString("RECORD_TYPE").ToString() == "INS")
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
{
cmd = new SqlCommand("UPDATE DO_Table SET DO_date ='" +
Convert.ToDateTime(dotable.ElementAt(i).GetString("BLDAT").ToString()) + "',DO_Customer ='" +
dotable.ElementAt(i).GetString("KUNNR").ToString() + "',DO_Barcode ='" +
dotable.ElementAt(i).GetString("CHARG").ToString() + "',DO_Location='" +
dotable.ElementAt(i).GetString("LOCATION").ToString() + "' WHERE DO_NO='" +
dotable.ElementAt(i).GetString("VBELN").ToString() + "'", con);
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
else
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
else
bapisaplist.Invoke(mydestination);
if (saptable.RowCount > 0)
lblfechdata2.Text = DateTime.Now + " Featch " + saptable.RowCount + " Records From sap
Sap_table";
if (saptable.ElementAt(i).GetString("NO_OF_PSC").ToString() == "")
hold = 0;
else
hold = Convert.ToDouble(saptable.ElementAt(i).GetString("NO_OF_PSC").ToString() ==
"");
if (saptable.ElementAt(i).GetString("RECORD_TYPE").ToString() == "INS")
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
else {
cmd = new SqlCommand("INSERT INTO
Sap_Table(SAP_Batch_No,SAP_Prod_Id,SAP_Prod_Name,SAP_Heat_No,SAP_Grade,SAP_Size,SAP_Lengt
h,SAP_Width,SAP_Thick,SAP_Finish,SAP_Edge,SAP_Quality,SAP_Net_Weight,SAP_NoOfPcs,SAP_Prod_T
ype,SAP_Serial_No,SAP_Gross_Weight,SAP_Customer,SAP_PackType) VALUES('" +
saptable.ElementAt(i).GetString("CHARG").ToString() + "','" +
saptable.ElementAt(i).GetString("COIL_NO").ToString() + "','','" +
saptable.ElementAt(i).GetString("HEAT_NO").ToString() + "','" +
saptable.ElementAt(i).GetString("GRADE").ToString() + "','','" +
saptable.ElementAt(i).GetString("LENGTH").ToString() + "','" +
saptable.ElementAt(i).GetString("WIDTH").ToString() + "','" +
saptable.ElementAt(i).GetString("THICKNESS").ToString() + "','" +
saptable.ElementAt(i).GetString("FINISH").ToString() + "','" +
saptable.ElementAt(i).GetString("EDGE").ToString() + "','" +
saptable.ElementAt(i).GetString("QUALITY").ToString() + "',0," + hold + ",0,'',0,'','')", con);
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
else
if (ds != null)
impStruct.SetValue("CHARG", dr["SAP_Batch_No"].ToString());
impStruct.SetValue("LOCATION", dr["SAP_Location"].ToString());
func.Invoke(dest);
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
lblsend.Text = DateTime.Now + " : Send " + ds.Tables[0].Rows.Count + " Records to sap From
Sql Server";
else
this.Lbl_Clr();
lblctn.Text = ex.Message.ToString();
txtreader.Text = ex.Message.ToString();
return;
con.Close();
if (Error_Msg == "")
{
if (path == "C:\\sap\\SapSend_Dtls.txt")
tsw.WriteLine(ErrorMsg[i].ToString());
tsw.WriteLine("\n" +
"____________________________________________________________________________________
__________________________");
tsw.Close();
tw.WriteLine(ErrorMsg[i].ToString());
tw.Close();
else
TextWriter tsw2;
if (path == "C:\\sap\\PrvLog_Dtls.txt")
else
tsw2.WriteLine(DateTime.Now);
tsw2.WriteLine("Error Message");
tsw2.WriteLine(Error_Msg);
tsw2.WriteLine("\n" +
"____________________________________________________________________________________
__________________________");
tsw2.Close();
grdcon.DataSource = view;
lblctn.Text = "";
lblfechdata.Text = "";
lblfun.Text = "";
lblsndsql.Text = "";
lblfechdata2.Text = "";
lblfun2.Text = "";
lblsndsql2.Text = "";
lblsend.Text = "";
lblfetch.Text = "";
lblsqlcon.Text = "";
lblsqlfun.Text = "";
try
grvtab.Visible = false;
txtreader.Visible = true;
txtreader.Text = myFile.ReadToEnd();
myFile.Close();
return;
}
}
txtreader.Visible = false;
grvtab.Visible = true;
txtreader.Visible = false;
grvtab.Visible = true;
Application.Exit();
{
DataTable dt = new DataTable();
da.Fill(ds);
dt = ds.Tables[0];
return dt;
int holdvl;
dt = this.SqlAccess(qry);
if (dt.Rows.Count != 0) {
holdvl = 1;
return holdvl;
}
}
App.config
<?xml version='1.0'?>
<configuration>
<configSections>
<sectionGroup name='SAP.Middleware.Connector'>
<sectionGroup name='ClientSettings'>
</sectionGroup>
<sectionGroup name='ServerSettings'>
</sectionGroup>
</sectionGroup>
</configSections>
<appSettings>
<SAP.Middleware.Connector>
<ClientSettings>
<DestinationConfiguration>
<destinations>
</destinations>
</DestinationConfiguration>
</ClientSettings>
<ServerSettings>
<ServerConfiguration>
<servers>
</servers>
</ServerConfiguration>
</ServerSettings>
</SAP.Middleware.Connector>
<startup>
</startup>
</configuration>
Error debug
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>