Public Sub ExportTableData(ByVal ConnectionStr As String, ByVal TableName As String, _
ByRef oView As DataView, _
ByVal SelectSQL As String, ByVal WhereSQL As String)
'Export SQL table to data view
Try
strSQL = ""
oCmd = Nothing
oDA = Nothing
oConn = New SqlConnection("server=192.9.200.82;database=eKalyan;user id=invite;password=invite")
oCmd = oConn.CreateCommand()
If SelectSQL.Length = 0 Then
strSQL = "SELECT newuniqueid as UNIQ_ID,newteh_code as TEH_CD,newpcate_cd as PCATE_CD,newplano as PLA_NO, pen_nm,rel_cd,pen_fnm,ccate_cd,pan_code as PAN_CD,pvillage as VILLAGE,ppo_cd as PO_CD,spo_cd,start_qtr,last_qtr,bundle_typ,bundle_no,mo_srno,pen_amt,pen_comm,status,operatorcode FROM " & "ekalyan.welpen"
'strSQL = "SELECT newuniqueid ,newteh_code ,newpcate_cd,newplano , pen_nm,rel_cd,pen_fnm,ccate_cd,pan_code ,pvillage ,ppo_cd ,spo_cd,start_qtr,last_qtr,bundle_typ,bundle_no,mo_srno,pen_amt,pen_comm,status,operatorcode FROM " & "ekalyan.welpen"
Else
strSQL = "SELECT " & SelectSQL & " FROM " & "ekalyan.welpen"
End If
If WhereSQL.Length > 0 Then
strSQL = strSQL & " WHERE " & WhereSQL
End If
'strSQL = "select newuniqueid,newteh_code,newpcate_cd,newplano, pen_nm,rel_cd,pen_fnm,ccate_cd,pan_code,pvillage,ppo_cd,spo_cd,start_qtr,last_qtr,bundle_typ,bundle_no,mo_srno,pen_amt,pen_comm,status,operatorcode from ekalyan.welpen"
oCmd.CommandText = strSQL
oDA = New SqlDataAdapter(oCmd)
oRS = New DataSet
oDA.Fill(oRS, "ekalyan.welpen")
oView = New DataView(oRS.Tables(0))
oConnOleDb.Close()
oConn = Nothing
oDA = Nothing
oRS = Nothing
oCmd = Nothing
'ExportTableData("server=192.9.200.82;database=eKalyan;user id=invite;password=invite", "ekalyan.welpen", oView, "", "")
MessageBox.Show("data exported Successfully")
Catch ex As Exception
End Try
End Sub
Public Sub ImportTableData(ByVal ConnectionStr As String, ByVal welfare_pen As String, _
ByRef oImportView As DataView, _
ByVal SelectSQL As String, ByVal WhereSQL As String)
Try
strSQL1 = ""
oConnOleDb = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\database1.mdb")
oConnOleDb.Open()
oCmdOleDb = Nothing
oDAOleDb = Nothing
oCmdOleDb = oConnOleDb.CreateCommand()
If SelectSQL.Length = 0 Then
strSQL1 = "SELECT newuniqueid as UNIQ_ID,newteh_code as TEH_CD,newpcate_cd as PCATE_CD,newplano as PLA_NO, pen_nm,rel_cd,pen_fnm,ccate_cd,pan_code as PAN_CD,pvillage as VILLAGE,ppo_cd as PO_CD,spo_cd,start_qtr,last_qtr,bundle_typ,bundle_no,mo_srno,pen_amt,pen_comm,status,operatorcode FROM " & "welfare_pen"
Else
strSQL = "SELECT " & SelectSQL & " FROM " & welfare_pen
End If
If WhereSQL.Length > 0 Then
strSQL1 = strSQL1 & " WHERE " & WhereSQL
End If
strSQL1 = "SELECT * FROM welfare_pen"
oCmdOleDb.CommandText = strSQL1
oDAOleDb = New OleDbDataAdapter(oCmdOleDb)
oRS1 = New DataSet
oDAOleDb.Fill(oRS1, "welfare_pen")
oView = New DataView(oRS.Tables(0))
oView.Table.Merge(oImportView.ToTable, True, MissingSchemaAction.Ignore)
Dim oCmdBuilder As OleDbCommandBuilder
oCmdBuilder = New OleDbCommandBuilder(oDAOleDb)
oDAOleDb.Update(oView.Table)
oConnOleDb.Close()
oConnOleDb = Nothing
oDAOleDb = Nothing
oRS1 = Nothing
oCmdOleDb = Nothing
'ImportTableData("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\database1.mdb", "welfare_pen", oView, "", "")
MessageBox.Show("data Imported Successfully")
DisplayCustomerCount()
Catch ex As Exception
End Try
End Sub
MappedSelect = "SELECT newuniqueid as UNIQ_ID,newteh_code as TEH_CD,newpcate_cd as PCATE_CD,newplano as PLA_NO, pen_nm,rel_cd,pen_fnm,ccate_cd,pan_code as PAN_CD,pvillage as VILLAGE,ppo_cd as PO_CD,spo_cd,start_qtr,last_qtr,bundle_typ,bundle_no,mo_srno,pen_amt,pen_comm,status,operatorcode FROM " & "ekalyan.welpen"
ExportTableData("server=192.9.200.82;database=eKalyan;user id=invite;password=invite", "ekalyan.welpen", oView, "MappedSelect", "")
DisplayrecordCount()