| Blogs \ Record of project 13-nov |
vex-
@ 13th November 2008 18:02.
|
|
Private Sub checkForUpdates() Label2.Text = Microsoft.WindowsMobile.Status.SystemProperty.PhoneSignalStrength If Long.Parse(Label2.Text.ToString().Trim()) > 10 Then Dim lastUpd As String Dim svc As New ezHandHeldService.Service() Dim ds As DataSet Dim SqlCommand As New SqlCeCommand("select lastupdated from engineer_details where userid = '" & Me.TextBox1.Text & "'", sqlConn2) sqlConn2.Open() lastUpd = SqlCommand.ExecuteScalar().ToString() sqlConn2.Close() Dim sqlcommandtext As String ds = svc.GetAllUpdatedRowsFromFirsttblGroup(lastUpd) '*******Will be GetAllUpdatedRows when merge DB * ' convert(DateTime '2008/10/10' 102) If ds.Tables.Count > 0 Then 'check updates For Each dt As DataTable In ds.Tables() Dim tblname As String tblname = "Error" Select Case dt.Columns(0).ColumnName Case "SerRecID" tblname = "ServiceRecords" Case "SiteID" tblname = "AlarmSite" Case "SqlQry" tblname = "CreateTablesData" Case "CustID" tblname = "Customers" Case "DelID" tblname = "DelTable" Case "id" tblname = "ImagesTable" Case "ProductID" tblname = "Products" Case "PartID" tblname = "ServicePartsList" Case "CallType" tblname = "tblCallTypes" Case "ServiceID" tblname = "tblEmployeeTime" Case "DESCRIPT" tblname = "Zones" Case "StationID" tblname = "tblMonStations" Case "SiteContactID" tblname = "SiteContacts" Case "ItemID" tblname = "ServiceListItems" Case "System" tblname = "Systems" Case "Type" tblname = "tblContractTypes" Case "AreaCode" tblname = "tblAreaCodes" Case "EmployeeID" tblname = "Employees" Case "Category" tblname = "Categorys" Case "ProductID2" tblname = "DeviceDetails" Case "QuoteSpecificationID" tblname = "QuotesSpecifications" Case "QuoteDetailID" tblname = "QuoteDetails" End Select Dim cmdCols(0 To dt.Columns.Count) As String, currIndex As Integer = 0 Dim cmdRows(0 To dt.Columns.Count) As String For Each dc As DataColumn In dt.Columns() cmdCols(currIndex) = dc.ColumnName currIndex += 1 Next currIndex = 0 If dt.Rows.Count > 0 Then TestForm.BringToFront() TestForm.Show() TestForm.Label1.Text += " Updates available: " & tblname TestForm.Refresh() For Each dr As DataRow In dt.Rows() sqlcommandtext = "Update " & tblname & " set " If dr("Updated").ToString() = "" Then Else If Date.Compare(Date.Parse(lastUpd), Date.Parse(dr("Updated").ToString())) < 0 Then lastUpd = dr("Updated").ToString() End If End If For i As Integer = 0 To dt.Columns.Count - 1 If dt.Columns(i).DataType Is GetType(Integer) Then If dr(i).ToString().ToString().Replace("'", "") = "" Then cmdRows(i) = 0 Else cmdRows(i) = dr(i).ToString().Replace("'", "") End If Else cmdRows(i) = " '" & dr(i).ToString().Replace("'", "") & "' " End If sqlcommandtext += "[" & cmdCols(i) & "]" & " = " & cmdRows(i) If i = dt.Columns.Count - 1 Then Else sqlcommandtext += "," End If Next i If dt.Columns(0).DataType Is GetType(Integer) Then sqlcommandtext += "where " & dt.Columns(0).ColumnName & " = " & dr(0).ToString() & "; " Else sqlcommandtext += "where " & dt.Columns(0).ColumnName & " = '" & dr(0).ToString() & "'; " End If Try If dt.Columns(0).DataType Is GetType(Integer) Then Dim sqlcmndins As New SqlCeCommand("insert into " & tblname & " (" & dt.Columns(0).ColumnName & ") values (" & dr(0).ToString() & ")", sqlConn2) sqlConn2.Open() sqlcmndins.ExecuteNonQuery() sqlConn2.Close() Else Dim sqlcmndins As New SqlCeCommand("insert into " & tblname & " (" & dt.Columns(0).ColumnName & ") values ('" & dr(0).ToString() & "')", sqlConn2) sqlConn2.Open() sqlcmndins.ExecuteNonQuery() sqlConn2.Close() End If Catch ex As Exception Finally sqlConn2.Close() End Try Try Dim SqlCommand2 As New SqlCeCommand(sqlcommandtext, sqlConn2) ' add Updated = now() sqlConn2.Open() SqlCommand2.ExecuteNonQuery() sqlConn2.Close() Catch ex As Exception TestForm.Label1.Text += sqlcommandtext TestForm.BringToFront() TestForm.Refresh() TestForm.Show() Finally sqlConn2.Close() End Try Next Dim sqlcmndins2 As New SqlCeCommand("update engineer_details set lastupdated = '" & lastUpd & "'", sqlConn2) sqlConn2.Open() sqlcmndins2.ExecuteNonQuery() sqlConn2.Close() End If Next End If End If End Sub Public Sub firstBulkInsert() Dim svc As New ezHandHeldService.Service Dim ds As New DataSet ds = svc.GetBulkData2() Dim commandtext As String Dim commandtext2 As String commandtext2 = "" Dim count As Long count = 0 commandtext = "" For Each dt As DataTable In ds.Tables() commandtext2 = "" Dim tblname As String tblname = "Error" Select Case dt.Columns(0).ColumnName Case "SerRecID" tblname = "ServiceRecords" Case "SiteID" tblname = "AlarmSite" Case "SqlQry" tblname = "CreateTablesData" Case "CustID" tblname = "Customers" Case "DelID" tblname = "DelTable" Case "id" tblname = "ImagesTable" Case "ProductID" tblname = "Products" Case "PartID" tblname = "ServicePartsList" Case "CallType" tblname = "tblCallTypes" Case "ServiceID" tblname = "tblEmployeeTime" Case "DESCRIPT" tblname = "Zones" Case "StationID" tblname = "tblMonStations" Case "SiteContactID" tblname = "SiteContacts" Case "ItemID" tblname = "ServiceListItems" Case "System" tblname = "Systems" Case "Type" tblname = "tblContractTypes" Case "AreaCode" tblname = "tblAreaCodes" Case "EmployeeID" tblname = "Employees" Case "Category" tblname = "Categorys" Case "ProductID2" tblname = "DeviceDetails" Case "QuoteSpecificationID" tblname = "QuotesSpecifications" Case "QuoteDetailID" tblname = "QuoteDetails" End Select commandtext = " insert into " & tblname & " (" ' change count = 0 For Each dc As DataColumn In dt.Columns If count = 0 Then commandtext += "[" & dc.ColumnName & "]" Else commandtext += ", [" & dc.ColumnName & "]" End If count += 1 Next commandtext += ")" ' has all the columns -- insert into employeetable ( col1, col2 ) Dim commandtext3 As String = "" If dt.Rows.Count > 0 Then For Each dr As DataRow In dt.Rows commandtext2 += " VALUES (" Dim columncount As Long = dt.Columns.Count For i As Integer = 0 To columncount - 1 If i = columncount - 1 Then If dt.Columns(i).DataType Is GetType(Integer) Then '= System.Data.SqlDbType.Bit Then If dr(i).ToString().Replace("'", "").ToString().Replace(")", "").ToString().Replace("(", "").ToString() = "" Then commandtext2 += "0" Else commandtext2 += dr(i).ToString().Replace("'", "").ToString().Replace(")", "").ToString().Replace("(", "").ToString() End If Else commandtext2 += "'" & dr(i).ToString().Replace("'", "").ToString().Replace(")", "").ToString().Replace("(", "").ToString() & "'" End If Else ' insert into employeetable ( col1, col2 ) VLUES ( If dt.Columns(i).DataType Is GetType(Integer) Then '= System.Data.SqlDbType.Bit Then If dr(i).ToString().Replace("'", "").ToString().Replace(")", "").ToString().Replace("(", "").ToString() = "" Then commandtext2 += "0, " Else commandtext2 += dr(i).ToString().Replace("'", "").ToString().Replace(")", "").ToString().Replace("(", "").ToString() & ", " End If Else commandtext2 += "'" & dr(i).ToString().Replace("'", "").ToString().Replace(")", "").ToString().Replace("(", "").ToString() & "', " '*********** msg currecy End If End If ' insert into employeetable ( col1, col2 ) values(val1,val2) Next i commandtext2 += ")" ' commandtext = commandtext.Substring(0, Len(commandtext) - 2) ' commandtext.Substring(0, commandtext.Length - 2) commandtext3 = commandtext + commandtext2 Dim SqlCommand2 As New SqlCeCommand(commandtext3, sqlConn) '"Insert into Alarmsite (SiteID, SiteRef, Town, County, AreaCode, Telephone, CustID, Commissionedby, dateinstalled, InstalledYN, MonCompany, Discontinued, PanelLocation, EngCode, Note, Disconnected, NSAICertNo, Occupant, PremiseType, AlarmType, GardaURN) VALUES (" & dr(0).ToString() & ", '" & dr("SiteRef").ToString() & "', '" & dr("town").ToString() & "', '" & dr("County").ToString() & "', '" & dr("AreaCode").ToString() & "', '" & dr("Telephone").ToString() & "', " & dr("CustID").ToString() & ", '" & dr("Commissionedby").ToString() & "', '" & dr("DateInstalled").ToString().Replace("/", "-") & "', '" & dr("InstalledYN").ToString() & "', '" & dr("MonCompany").ToString() & "', '" & dr("Discontinued").ToString() & "', '" & dr("PanelLocation").ToString() & "', " & dr("EngCode").ToString() & ", '" & dr("Note").ToString() & "', '" & dr("Disconnected").ToString() & "', '" & dr("NSAICertNo").ToString() & "', '" & dr("Occupant").ToString() & "', '" & dr("PremiseType").ToString() & "', '" & dr("AlarmType").ToString() & "', '" & dr("GardaURN").ToString() & "')", sqlConn) '" & dr("DateInstalled").ToString().Replace("/", "-") & "' " & dr("CPanelProdID").ToString() & " '(SiteID, SiteRef, Address, Town, County, AreaCode, Telephone, CustID, Commissionedby, DateInstalled, InstalledYN, MonCompany, Discontinued, CPanelProdID, PanelLocation, EngCode, Note, Disconnected, NSAICertNo, Occupant, PremiseType, AlarmType, GardaURN, Installer, DigiNo, RenewalDate, MonFee, [Mon Commission], LastModified, ModifiedBy, SiteEnteredOn, SiteEnteredBy, OldNotes, CustomerType, RadioID, UserDefinedField1, UserDefinedField2, UserDefinedField3, UserDefinedField4, LabourRate, PercentRate, Password, UserCode, Letter, LastMaintDone, NextMaintDue, Pricing, Updated) commandtext2 = "" 'Try sqlConn.Open() SqlCommand2.ExecuteNonQuery() sqlConn.Close() 'Catch ex As Exception ' TestForm.Label1.Text += SqlCommand2.CommandText.ToString() ' TestForm.Refresh() ' TestForm.Show() 'End Try Next End If Next End Sub Public Sub CreateTables() Dim svc As New ezHandHeldService.Service Dim ds As New DataSet ds = svc.GetBulkData() Dim commandtext As String Dim commandtext2 As String commandtext2 = "" Dim count As Long commandtext = "" For Each dt As DataTable In ds.Tables() commandtext2 = "" Dim tblname As String tblname = "Error" Select Case dt.Columns(0).ColumnName Case "SerRecID" tblname = "ServiceRecords" Case "SiteID" tblname = "AlarmSite" Case "SqlQry" tblname = "CreateTablesData" Case "CustID" tblname = "Customers" Case "DelID" tblname = "DelTable" Case "id" tblname = "ImagesTable" Case "ProductID" tblname = "Products" Case "PartID" tblname = "ServicePartsList" Case "CallType" tblname = "tblCallTypes" Case "ServiceID" tblname = "tblEmployeeTime" Case "DESCRIPT" tblname = "Zones" Case "StationID" tblname = "tblMonStations" Case "SiteContactID" tblname = "SiteContacts" Case "ItemID" tblname = "ServiceListItems" Case "System" tblname = "Systems" Case "Type" tblname = "tblContractTypes" Case "AreaCode" tblname = "tblAreaCodes" Case "EmployeeID" tblname = "Employees" Case "Category" tblname = "Categorys" Case "ProductID2" tblname = "DeviceDetails" Case "QuoteSpecificationID" tblname = "QuotesSpecifications" Case "QuoteDetailID" tblname = "QuoteDetails" End Select count = 0 For Each dc As DataColumn In dt.Columns If count = 0 Then If dc.DataType Is GetType(Integer) Then '= System.Data.SqlDbType.Bit Then commandtext2 += "[" & dc.ColumnName.ToString() & "] int " Else commandtext2 += "[" & dc.ColumnName.ToString() & "] nVarchar(100)" End If Else If dc.DataType Is GetType(Integer) Then '= System.Data.SqlDbType.Bit Then commandtext2 += ", [" & dc.ColumnName.ToString() & "] int " Else commandtext2 += ", [" & dc.ColumnName.ToString() & "] nVarchar(100) " End If End If count += 1 Next Dim sqltext As String sqltext = "Create Table " & tblname & " (" & commandtext2 & ") " 'tblname Dim SqlCommand2 As New SqlCeCommand(sqltext, sqlConn) commandtext2 = "" 'TestForm.Label1.Text += SqlCommand2.CommandText.ToString() 'TestForm.Refresh() 'TestForm.Show() sqlConn.Open() SqlCommand2.ExecuteNonQuery() sqlConn.Close() tblname = "" sqltext = "" Next End Sub IT TOOK 3 DAYS jus gottta back it up till i get home |
man what programming language is this?
vvvvvvvvvvvvvvvvvvvvvvvvvvveeeeeeeeeeeeeeeeeeeexxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
wtf is this VB programm doing? lolz;d
its uhh...
well its complicated. xD
its on a handheld pocket pc, using .net compact 3.5
it basically copys a table structure from one database to another, then copys each row of each field one by one.
the top method only takes rows that are changed on one database and not on the handheld database, using an "updated" date-time field :/!!!
it was a NIGHTMARE!
i fucking hate compact framework!
well its complicated. xD
its on a handheld pocket pc, using .net compact 3.5
it basically copys a table structure from one database to another, then copys each row of each field one by one.
the top method only takes rows that are changed on one database and not on the handheld database, using an "updated" date-time field :/!!!
it was a NIGHTMARE!
i fucking hate compact framework!
Top levels
37
|
| Raistlin | |
27
|
| Mazor | |
24
|
| Kusel | |
24
|
| poGDI | |
23
|
| kOoZiN | |
21
|
| 000.Zulu | |
20
|
| GpZ)Zork( | |
19
|
| cYaN | |
19
|
| LML | |
18
|
| KoenigFrederik | |
18
|
| Lord_of_Chaos | |
18
|
| zoxxer | |
17
|
| Salieri | |
16
|
| Entropy | |
16
|
| vildamalin | |
15
|
| Xeris[LighT] | |
15
|
| LeiZ | |
14
|
| MgZ)Makinon | |
14
|
| Return[SomE] | |
13
|
| Genie | |
13
|
| LordWeird | |
13
|
| Forgotten | |
13
|
| synergis | |
13
|
| Artanis | |
12
|
| Ekii(IIF) |
Orion
Legend
5min
DoC
DL)
5h20m
Tuffer
MorroW
5h20m
ExGoSu
FremAN
5h20m
CleqNer.
QcK
5h20m
SquaLL
PrO
5h20m
Latest from the forums
(118)
Israel hits UN school
(36)
Canada ROCKS
(29)
Greek Mythology
(15)
2009 OK!?
(23)
pimpest play 2009
(0)
Foreigner PvP
(14)
hold posision lurker
(19)
Another TvP thread!
(30)
I like zerg, but...
(41)
SC2 Beta?
(19)
GosuCup #1
Poll
What do you think of fnatic SC:BW squad? (937 votes)
| I dont care | (37%) | ||
| They will change balance of all the leagues they take part in. | (34%) | ||
| They won't change anything. | (28%) | ||







Search
1
UltraLinG