Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
connetionString = ("server=192.9.200.82;database=eKalyan;user id=invite;password=invite")
MessageBox.Show("connection established")
sql = ("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")
cnn = New SqlConnection(connetionString)
Try
cnn.Open()
cmdd = New SqlCommand(sql, cnn)
cmdd.ExecuteNonQuery()
cnn.Close()
MsgBox(" ExecuteNonQuery in SqlCommand executed !!")
Catch ex As Exception
MsgBox("cannot open the connection")
End Try
'Dim objdataadapter1 As New SqlDataAdapter("select Teh_code,Pcate_Cd,Wtng_No,Applicationdate,Pen_Nm,Rel_Cd1,Pen_Fnm,pan_code,Po_Cd,disabilitypercentage,Ccate_Cd,IndiviualsIncome,Village from ekalyan.WtngN", objconnection)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\database1.mdb")
cn.Open()
str = "insert into Table1(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) values (@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)IN 'C:\Table1.mdb'"
cmd = New OleDbCommand(str, cn)
icount = cmd.ExecuteNonQuery
cn = Nothing
MessageBox.Show(icount)
Catch
End Try
cn.Close()
End Sub
End Class
kritiohri
0
Newbie Poster
Recommended Answers
Jump to PostI had a code which uses data view to transfer from Access to SQL Server. All you have to modify to transfer from SQL Server to Access, is to change OleDB* variables (objects) to Sql* variables (objects) and vice versa.
Read Access table to data view:
Jump to PostOkay, your Button1 reads data and Button2 writes data. If you want to keep it that way, set
Dim oView As DataView
as global variable in your class (form), likePrivate oView As DataView
. PutExportTableData(SourceConnectionString, SourceTableName, oView, "", "")
in your Button1 andImportTableData(TargetConnectionString, …
Jump to PostHi! If your question is solved, please mark the thread as solved. Thank you!
All 22 Replies
Teme64
215
Veteran Poster
kritiohri
0
Newbie Poster
Teme64
215
Veteran Poster
kritiohri
0
Newbie Poster
kritiohri
0
Newbie Poster
Teme64
215
Veteran Poster
kritiohri
0
Newbie Poster
Teme64
215
Veteran Poster
kritiohri
0
Newbie Poster
Teme64
215
Veteran Poster
kritiohri
0
Newbie Poster
Teme64
215
Veteran Poster
kritiohri
0
Newbie Poster
kritiohri
0
Newbie Poster
Teme64
215
Veteran Poster
kritiohri
0
Newbie Poster
Teme64
215
Veteran Poster
kritiohri
0
Newbie Poster
kritiohri
0
Newbie Poster
Teme64
215
Veteran Poster
bhagawatshinde
11
Posting Whiz
elie.karkafy
0
Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.