Control List
- Three Form (MDI,save and Show)
- Text box , open file dialog ,button on save button
- Gridview,Picture Box , Label on show form
MDI Code :
Private Sub
SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
SaveToolStripMenuItem.Click
frmAdd.MdiParent = Me
frmAdd.Show()
End Sub
Private Sub ShowToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
ShowToolStripMenuItem.Click
frmShow.MdiParent = Me
frmShow.Show()
End Sub
Save Form Code
Private Sub
btnSave_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
btnSave.Click
If
txtName.Text = "" Or txtcity.Text = ""
Or OpenFileDialog1.FileName = "OpenFileDialog1" Then
MsgBox("Please provide all Data")
If
txtcity.Text = "" Then
txtcity.Focus()
ElseIf
txtName.Text = "" Then
txtName.Focus()
ElseIf
OpenFileDialog1.FileName = "OpenFileDialog1"
Then
Button1.Focus()
End
If
Else
Dim
con As New
OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=girfa.accdb")
Dim
com As New
OleDbCommand
Try
com.Connection = con
con.Open()
com.CommandText = "insert into stu (sname,city,pic) values('"
& txtName.Text & "','"
& txtcity.Text & "','"
& System.IO.Path.GetFileName(OpenFileDialog1.FileName) & "')"
com.ExecuteNonQuery()
FileCopy(OpenFileDialog1.FileName, Application.StartupPath & "\image\" &
System.IO.Path.GetFileName(OpenFileDialog1.FileName))
MsgBox("Record
Saved")
txtName.Text = ""
txtName.Focus()
txtcity.Text = ""
Catch
ex As Exception
MsgBox(ex.Message)
Finally
con.Close()
End
Try
End If
End Sub
Private Sub Button1_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
OpenFileDialog1.ShowDialog()
End Sub
Private Sub frmAdd_Click(ByVal
sender As Object,
ByVal e As
System.EventArgs) Handles Me.Click
System.Diagnostics.Process.Start("http://girfahelp.blogspot.in/p/vbnet-tutorial.html")
End Sub
No comments:
Post a Comment