Click here to Skip to main content
15,905,875 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionVB6 - Using Regular Expression against Unicode data [modified] Pin
stakemaster30-Nov-08 11:56
stakemaster30-Nov-08 11:56 
AnswerRe: Using Regular Expression against Unicode data Pin
Christian Graus30-Nov-08 16:35
protectorChristian Graus30-Nov-08 16:35 
QuestionHelp in Steganography Pin
sarfarazaliqureshi30-Nov-08 7:00
sarfarazaliqureshi30-Nov-08 7:00 
AnswerRe: Help in Steganography Pin
Christian Graus30-Nov-08 12:37
protectorChristian Graus30-Nov-08 12:37 
AnswerRe: Help in Steganography Pin
Paul Conrad30-Nov-08 14:09
professionalPaul Conrad30-Nov-08 14:09 
AnswerRe: Help in Steganography Pin
Mark Churchill30-Nov-08 17:24
Mark Churchill30-Nov-08 17:24 
GeneralRe: Help in Steganography Pin
sarfarazaliqureshi1-Dec-08 23:41
sarfarazaliqureshi1-Dec-08 23:41 
Questionupdate sql server database from access database [modified] Pin
zorronami30-Nov-08 6:25
zorronami30-Nov-08 6:25 
I have made some program that will be used to update the sql server database. The data was taken from Access Database. In other words, i tried to move the data from Access to Sql server. Here is the code that i developed :

Option Explicit

Public dbacc As ADODB.Connection
Public rsAcc As ADODB.Recordset
Public rsSql As ADODB.Recordset
Public dbSQL As ADODB.Connection
Public rsSql2 As ADODB.Connection

Public Sub Update()
Dim updaterec, updaterec2 As String
Dim sPath As String
Set dbacc = New ADODB.Connection
Set rsAcc = New ADODB.Recordset
Set rsSql = New ADODB.Recordset
Set dbSQL = New ADODB.Connection
Set rsSql2 = New ADODB.Connection
Dim sConnACC As String
sConnACC = "Provider=Microsoft.Jet.OLEDB.4.0;Data_ Source=\dbsimonev.mdb;"
Dim sSQL As String
sSQL = "SELECT * FROM tblData"
Dim sSQL2 As String
Dim sSQL3 As String
sSQL2 = "SELECT * FROM T3B_MON"
sSQL3 = "SELECT * FROM T3B_MONK"
dbacc.ConnectionString = sConnACC
dbacc.Open
dbSQL.Open _
"Provider = sqloledb;" & _
"Data Source={SANJILUFFYCOMP};" & _
"Initial Catalog={simonev};" & _
"User ID={UserName};" & _
"Password={Password};"

rsAcc.ActiveConnection = dbacc
rsAcc.LockType = adLockOptimistic
rsAcc.CursorType = adOpenKeyset
Set rsAcc = dbacc.Execute(sSQL)

rsSql.ActiveConnection = dbSQL
rsSql.LockType = adLockOptimistic
rsSql.CursorType = adOpenKeyset
Set rsSql = dbSQL.Execute(sSQL2)

rsSql2.ActiveConnection = dbSQL
rsSql2.LockType = adLockOptimistic
rsSql2.CursorType = adOpenKeyset
Set rsSql2 = dbSQL.Execute(sSQL3)

Do While Not rsSql.EOF
rsSql.MoveNext
Do While Not rsAcc.EOF
rsAcc.MoveNext
If rsAcc(1).Value = rsSql(1).Value Then
If rsSql(3).Value = rsAcc(2).Value Then
If rsSql(2).Value = rsAcc(3).Value Then
If rsAcc(4).Value <> rsSql(17).Value Then
If rsAcc(2).Value = 1 Then
updaterec = "INSERT T3B_MON (KDSATKER,BULAN,TAHUN,TARGET01,REALIS01) values (rsAcc(1).Value , rsAcc(3).Value, rsAcc(2).Value, rsAcc(4).Value*1000000, rsAcc(5).Value*1000000)"
updaterec2 = "INSERT T3B_MONK (KDSATKER,BULAN,TAHUN,TARGET01,REALIS01) values (rsAcc(1).Value, rsAcc(3).Value, rsAcc(2).Value, rsAcc(6).Value*1000000, rsAcc(7).Value*1000000)"
End If
If rsAcc(2).Value = 2 Then
updaterec = "INSERT T3B_MON (KDSATKER,BULAN,TAHUN,TARGET02,REALIS02) values (rsAcc(1).Value , rsAcc(3).Value, rsAcc(2).Value, rsAcc(4).Value*1000000, rsAcc(5).Value*1000000)"
updaterec2 = "INSERT T3B_MONK (KDSATKER,BULAN,TAHUN,TARGET02,REALIS02) values (rsAcc(1).Value, rsAcc(3).Value, rsAcc(2).Value, rsAcc(6).Value*1000000, rsAcc(7).Value*1000000)"
End If
If rsAcc(2).Value = 3 Then
updaterec = "INSERT T3B_MON (KDSATKER,BULAN,TAHUN,TARGET03,REALIS03) values (rsAcc(1).Value , rsAcc(3).Value, rsAcc(2).Value, rsAcc(4).Value*1000000, rsAcc(5).Value*1000000)"
updaterec2 = "INSERT T3B_MONK (KDSATKER,BULAN,TAHUN,TARGET03,REALIS03) values (rsAcc(1).Value, rsAcc(3).Value, rsAcc(2).Value, rsAcc(6).Value*1000000, rsAcc(7).Value*1000000)"
End If
If rsAcc(2).Value = 4 Then
updaterec = "INSERT T3B_MON (KDSATKER,BULAN,TAHUN,TARGET04,REALIS04) values (rsAcc(1).Value , rsAcc(3).Value, rsAcc(2).Value, rsAcc(4).Value*1000000, rsAcc(5).Value*1000000)"
updaterec2 = "INSERT T3B_MONK (KDSATKER,BULAN,TAHUN,TARGET04,REALIS04) values (rsAcc(1).Value, rsAcc(3).Value, rsAcc(2).Value, rsAcc(6).Value*1000000, rsAcc(7).Value*1000000)"
End If
If rsAcc(2).Value = 5 Then
updaterec = "INSERT T3B_MON (KDSATKER,BULAN,TAHUN,TARGET05,REALIS05) values (rsAcc(1).Value , rsAcc(3).Value, rsAcc(2).Value, rsAcc(4).Value*1000000, rsAcc(5).Value*1000000)"
updaterec2 = "INSERT T3B_MONK (KDSATKER,BULAN,TAHUN,TARGET05,REALIS05) values (rsAcc(1).Value, rsAcc(3).Value, rsAcc(2).Value, rsAcc(6).Value*1000000, rsAcc(7).Value*1000000)"
End If
If rsAcc(2).Value = 6 Then
updaterec = "INSERT T3B_MON (KDSATKER,BULAN,TAHUN,TARGET06,REALIS06) values (rsAcc(1).Value , rsAcc(3).Value, rsAcc(2).Value, rsAcc(4).Value*1000000, rsAcc(5).Value*1000000)"
updaterec2 = "INSERT T3B_MONK (KDSATKER,BULAN,TAHUN,TARGET06,REALIS06) values (rsAcc(1).Value, rsAcc(3).Value, rsAcc(2).Value, rsAcc(6).Value*1000000, rsAcc(7).Value*1000000)"
End If
If rsAcc(2).Value = 7 Then
updaterec = "INSERT T3B_MON (KDSATKER,BULAN,TAHUN,TARGET07,REALIS07) values (rsAcc(1).Value , rsAcc(3).Value, rsAcc(2).Value, rsAcc(4).Value*1000000, rsAcc(5).Value*1000000)"
updaterec2 = "INSERT T3B_MONK (KDSATKER,BULAN,TAHUN,TARGET07,REALIS07) values (rsAcc(1).Value, rsAcc(3).Value, rsAcc(2).Value, rsAcc(6).Value*1000000, rsAcc(7).Value*1000000)"
End If
If rsAcc(2).Value = 8 Then
updaterec = "INSERT T3B_MON (KDSATKER,BULAN,TAHUN,TARGET08,REALIS08) values (rsAcc(1).Value , rsAcc(3).Value, rsAcc(2).Value, rsAcc(4).Value*1000000, rsAcc(5).Value*1000000)"
updaterec2 = "INSERT T3B_MONK (KDSATKER,BULAN,TAHUN,TARGET08,REALIS08) values (rsAcc(1).Value, rsAcc(3).Value, rsAcc(2).Value, rsAcc(6).Value*1000000, rsAcc(7).Value*1000000)"
End If
If rsAcc(2).Value = 9 Then
updaterec = "INSERT T3B_MON (KDSATKER,BULAN,TAHUN,TARGET09,REALIS09) values (rsAcc(1).Value , rsAcc(3).Value, rsAcc(2).Value, rsAcc(4).Value*1000000, rsAcc(5).Value*1000000)"
updaterec2 = "INSERT T3B_MONK (KDSATKER,BULAN,TAHUN,TARGET09,REALIS09) values (rsAcc(1).Value, rsAcc(3).Value, rsAcc(2).Value, rsAcc(6).Value*1000000, rsAcc(7).Value*1000000)"
End If
If rsAcc(2).Value = 10 Then
updaterec = "INSERT T3B_MON (KDSATKER,BULAN,TAHUN,TARGET10,REALIS10) values (rsAcc(1).Value , rsAcc(3).Value, rsAcc(2).Value, rsAcc(4).Value*1000000, rsAcc(5).Value*1000000)"
updaterec2 = "INSERT T3B_MONK (KDSATKER,BULAN,TAHUN,TARGET10,REALIS10) values (rsAcc(1).Value, rsAcc(3).Value, rsAcc(2).Value, rsAcc(6).Value*1000000, rsAcc(7).Value*1000000)"
End If
If rsAcc(2).Value = 11 Then
updaterec = "INSERT T3B_MON (KDSATKER,BULAN,TAHUN,TARGET11,REALIS11) values (rsAcc(1).Value , rsAcc(3).Value, rsAcc(2).Value, rsAcc(4).Value*1000000, rsAcc(5).Value*1000000)"
updaterec2 = "INSERT T3B_MONK (KDSATKER,BULAN,TAHUN,TARGET11,REALIS11) values (rsAcc(1).Value, rsAcc(3).Value, rsAcc(2).Value, rsAcc(6).Value*1000000, rsAcc(7).Value*1000000)"
End If
If rsAcc(2).Value = 12 Then
updaterec = "INSERT T3B_MON (KDSATKER,BULAN,TAHUN,TARGET12,REALIS12) values (rsAcc(1).Value , rsAcc(3).Value, rsAcc(2).Value, rsAcc(4).Value*1000000, rsAcc(5).Value*1000000)"
updaterec2 = "INSERT T3B_MONK (KDSATKER,BULAN,TAHUN,TARGET12,REALIS12) values (rsAcc(1).Value, rsAcc(3).Value, rsAcc(2).Value, rsAcc(6).Value*1000000, rsAcc(7).Value*1000000)"
End If
End If

Set rsSql = dbSQL.Execute(updaterec)
Set rsSql = dbSQL.Execute(updaterec2)
End If
End If
End If
rsAcc.MoveNext
Loop
rsSql.MoveNext
Loop
MsgBox "update is finished"
rsSql.Close
rsAcc.Close
Set rsSql = Nothing
Set rsAcc = Nothing
dbacc.Close
dbSQL.Close
Set dbacc = Nothing
Set dbSQL = Nothing
End Sub

when i compiled it, nothing was error, all worked fine. But the problem is nothing happened to the sql server database when i executed this program. Nothing was updated in the sql server database. What could make it wrong or why didn't something happen??. is it because the code or another else?

Please need your help.

Thanks in advance.

modified on Sunday, November 30, 2008 12:33 PM

AnswerRe: update sql server database from access database Pin
Wendelius30-Nov-08 11:25
mentorWendelius30-Nov-08 11:25 
QuestionInteract with the telephone system in .Net Pin
wdeepu30-Nov-08 4:27
wdeepu30-Nov-08 4:27 
AnswerRe: Interact with the telephone system in .Net Pin
Wendelius30-Nov-08 4:35
mentorWendelius30-Nov-08 4:35 
GeneralRe: Interact with the telephone system in .Net Pin
Paul Conrad30-Nov-08 6:39
professionalPaul Conrad30-Nov-08 6:39 
GeneralRe: Interact with the telephone system in .Net Pin
Wendelius30-Nov-08 12:09
mentorWendelius30-Nov-08 12:09 
GeneralRe: Interact with the telephone system in .Net Pin
Paul Conrad30-Nov-08 14:09
professionalPaul Conrad30-Nov-08 14:09 
GeneralRe: Interact with the telephone system in .Net Pin
wdeepu30-Nov-08 18:09
wdeepu30-Nov-08 18:09 
GeneralRe: Interact with the telephone system in .Net Pin
Paul Conrad30-Nov-08 18:12
professionalPaul Conrad30-Nov-08 18:12 
GeneralRe: Interact with the telephone system in .Net Pin
wdeepu30-Nov-08 20:58
wdeepu30-Nov-08 20:58 
GeneralRe: Interact with the telephone system in .Net Pin
Wendelius1-Dec-08 4:39
mentorWendelius1-Dec-08 4:39 
QuestionShutdown Computer Pin
Pasan14829-Nov-08 22:58
Pasan14829-Nov-08 22:58 
AnswerRe: Shutdown Computer Pin
Wendelius29-Nov-08 23:13
mentorWendelius29-Nov-08 23:13 
GeneralRe: Shutdown Computer Pin
Pasan14830-Nov-08 3:44
Pasan14830-Nov-08 3:44 
GeneralRe: Shutdown Computer Pin
Wendelius30-Nov-08 4:35
mentorWendelius30-Nov-08 4:35 
GeneralRe: Shutdown Computer Pin
Paul Conrad30-Nov-08 6:42
professionalPaul Conrad30-Nov-08 6:42 
AnswerRe: Shutdown Computer Pin
mohantech30-Nov-08 23:03
mohantech30-Nov-08 23:03 
QuestionVB2008 and Outlook 2007 - Trying to pull contacts from a specific contact folder Pin
rdean3029-Nov-08 15:03
rdean3029-Nov-08 15:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.