rajkumar.shukla
Member
- Joined
- Feb 3, 2015
- Messages
- 8
- Programming Experience
- Beginner
Hi, I've created a windowsform application into VB.net using excel as a data base. one the button click even all the filled data export into the excel file. now I want on the same time one particular excel value come into the windows form defined text box.
below is the code. please modify the same.
Imports System.Data.OleDb
Public Class Form1
Dim Cn As New OleDbConnection
Dim cm As New OleDbCommand
Private Sub BtnSave_Click(sender As System.Object, e As System.EventArgs) Handles BtnSave.Click
Cn.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=C:\Users\rajkumar.shukla\Desktop\Testing\testing.xlsm;extended properties=excel 8.0"
Cn.Open()
With cm
.Connection = Cn
.CommandText = "insert into [testing$]values('" & TxtComp.Text & "','" & TxtDep.Text & "','" & TxtVer.Text & "','" & TxtDat.Text & "', '" & TxtIni.Text & "','" & TxtSig.Text & "','" & TxtSub.Text & "','" & Txtyear.Text & "')"
.ExecuteNonQuery()
End With
Cn.Close()
MsgBox("Reference Number Generate Successfully", MsgBoxStyle.Information, Text)
End Sub
End Class
below is the code. please modify the same.
Imports System.Data.OleDb
Public Class Form1
Dim Cn As New OleDbConnection
Dim cm As New OleDbCommand
Private Sub BtnSave_Click(sender As System.Object, e As System.EventArgs) Handles BtnSave.Click
Cn.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=C:\Users\rajkumar.shukla\Desktop\Testing\testing.xlsm;extended properties=excel 8.0"
Cn.Open()
With cm
.Connection = Cn
.CommandText = "insert into [testing$]values('" & TxtComp.Text & "','" & TxtDep.Text & "','" & TxtVer.Text & "','" & TxtDat.Text & "', '" & TxtIni.Text & "','" & TxtSig.Text & "','" & TxtSub.Text & "','" & Txtyear.Text & "')"
.ExecuteNonQuery()
End With
Cn.Close()
MsgBox("Reference Number Generate Successfully", MsgBoxStyle.Information, Text)
End Sub
End Class