Sunday, February 14, 2021

DiversityGlobal Magazine

DiversityGlobal Magazine: DiversityGlobal is a quarterly magazine for C-Suite executives and professionals responsible for driving change internally and across cultures. It is one of the most widely read diversity magazines in Asia, North America, and Europe.

Friday, May 28, 2010

Inserting new record into Access database with VB.Net


Imports System.Data.Odbc
Partial Class New_Customer
Inherits System.Web.UI.Page
Dim con As New OdbcConnection("Dsn=JLCB")

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim insert As String
insert = "Insert into customer values('" & TextBox0.Text & "','" & TextBox1.Text & "'," & TextBox2.Text & "," & TextBox3.Text & ",'" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "','" & TextBox7.Text & "','" & TextBox8.Text & "','" & TextBox9.Text & "','" & TextBox10.Text & "','" & TextBox11.Text & "','" & DropDownList1.Text & "')"
Dim com1 As New OdbcCommand(insert, con)
Dim x As Integer
Try
con.Open()
x = com1.ExecuteNonQuery
MsgBox("Record Inserted Sucessfully")
clear()
Catch ex As Exception
MsgBox("Please check info carefully. Make sure 'ID' provided is available or not.")
Finally
con.Close()
End Try
End Sub

Transactions with accounts in banking


Imports System.Data.Odbc
Partial Class Transactions
Inherits System.Web.UI.Page
Dim x As Date = Date.Today.ToShortDateString
Dim con As New OdbcConnection("Dsn=MYODBC")
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = TextBox1.Text.ToUpper()
Dim str As String
str = "Select * from trans where acno='" & TextBox1.Text & "' order by tid desc"
Dim com As New OdbcCommand(str, con)
Dim r As OdbcDataReader
Try
con.Open()
r = com.ExecuteReader
r.Read()
TextBox2.Text = r("BalAftTrans")
Label1.Text = Val(r("tid")) + 1
r.Close()
Label3.Text = x
Label1.Visible = True
Label2.Visible = True
Label3.Visible = True
TextBox2.Visible = True
DropDownList1.Visible = True
TextBox4.Visible = True
Button3.Visible = True
'MsgBox("Account Found")
Catch ex As Exception
MsgBox(ex.Message)
Finally
con.Close()
End Try


End Sub

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
If DropDownList1.Text = "Debit" Then
If Val(TextBox2.Text) <= 300 Then
MsgBox("Account with minimum balance only. Withdraw not allowed", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Invalied Transaction")
ElseIf Val(TextBox4.Text) > (Val(TextBox2.Text) - 300) Then
MsgBox("Insufficient funds in your account. Withdraw not allowed", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Invalied Transaction")
Else
Label2.Text = Val(TextBox2.Text) - Val(TextBox4.Text)
inputs()
End If
Else
Label2.Text = Val(TextBox2.Text) + Val(TextBox4.Text)
inputs()
End If
End Sub
Private Sub inputs()
Dim tra As String
tra = "Insert into trans values(" & Label1.Text & ",'" & TextBox1.Text & "','" & Label3.Text & "','" & DropDownList1.Text & "','" & Label4.Text & "'," & TextBox4.Text & "," & TextBox2.Text & "," & Label2.Text & ")"
Dim com1 As New OdbcCommand(tra, con)
Try
con.Open()
Dim a As Integer
a = com1.ExecuteNonQuery
MsgBox(DropDownList1.Text & " sucessfully Completed. your Account balance is Rs." & Label2.Text, MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "Transaction info")
Response.Redirect("New_Account.aspx")
Catch ex As Exception
MsgBox(ex.Message)
Finally
con.Close()
End Try
End Sub

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

End Sub


End Class