| | |
Update Command in Vb.net
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2008
Posts: 10
Reputation:
Solved Threads: 0
i am writing a code where the user will update the staff,but my update command has some problems. i think its the comma's in my command,can somebody help me.......
this is my code
this is my code
vbnet Syntax (Toggle Plain Text)
Imports System.Data.OleDb Public Class EditDeleteStaff Dim PwdCon As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "/Blindz.mdb; Jet OLEDB:Database Password=;" 'Persist Security Info=False;" if your DB is not PWD protected Dim oledbcon As New OleDbConnection(PwdCon) Dim dsID As New DataSet() Dim daID As New OleDbDataAdapter() Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click Me.Hide() Manager.Show() End Sub Private Sub EditDeleteStaff_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim PwdCon As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "/Blindz.mdb; Jet OLEDB:Database Password=;" Dim oledbcon As New OleDbConnection(PwdCon) End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim jobstat As String = "" Dim num1, num2, num3, num4, num5, num6 As Boolean Dim phone, icnum, genId As String Dim i As Integer = 0 num1 = IsNumeric(telbox.Text) num2 = IsNumeric(telbox2.Text) num3 = IsNumeric(IcNumbox.Text) num4 = IsNumeric(IcNumbox2.Text) num5 = IsNumeric(IcNumbox3.Text) num6 = IsChar(namebox.Text) If Ftime.Checked = True Then jobstat = Ftime.Text End If If Ptime.Checked = True Then jobstat = Ptime.Text End If 'THIS ALL CHANGE TO UPDATEEEE!!!!! If namebox.Text = "" OrElse _ addbox.Text = "" OrElse _ telbox2.Text = "" OrElse _ telbox.Text = "" OrElse _ syspass.Text = "" OrElse _ IcNumbox.Text = "" OrElse _ IcNumbox2.Text = "" OrElse _ IcNumbox3.Text = "" OrElse _ posbox.Text = "" OrElse _ jobstat = "" Then MessageBox.Show("All feilds must be filled") ElseIf num1 = False Or num2 = False Or num3 = False Or num4 = False Or num5 = False Then MessageBox.Show("Ic number and telephone number cannot have characters") ElseIf num6 = False Then MessageBox.Show("Name Cannot Contain Numbers") ElseIf telbox.TextLength < 2 Or telbox2.TextLength < 7 Then MessageBox.Show("Not a Valid telephone Number") ElseIf IcNumbox.TextLength < 6 Or IcNumbox2.TextLength < 2 Or IcNumbox3.TextLength < 4 Then MessageBox.Show("Not a Valid Malaysian Ic Number") Else phone = telbox.Text + "-" + telbox2.Text icnum = IcNumbox.Text + "-" + IcNumbox2.Text + "-" + IcNumbox3.Text Try oledbcon.Open() Dim strSQL As String = ("UPDATE Staff SET StaffName = [" & namebox.Text & "] ,Address = [" & addbox.Text & "] ,Phone = [" & phone & "] ,JobPosition = [" & posbox.Text & "] ,JobStat = [" & genId & "] WHERE {SID=" & id.Text & "}") Dim cmd As OleDbCommand = New OleDbCommand(strSQL, oledbcon) Dim objread As OleDbDataReader objread = cmd.ExecuteReader Catch ex As Exception MessageBox.Show(ex.Message) Finally oledbcon.Close() End Try End If End Sub
Last edited by cscgal; Oct 12th, 2008 at 4:34 pm. Reason: Added code tags
Enclose text field values in quotes:
If SID field is numeric, remove quotes from it.
VB.NET Syntax (Toggle Plain Text)
Dim strSQL As String = ("UPDATE Staff SET StaffName = ['" & _ namebox.Text & "'] ,Address = ['" & addbox.Text & _ "'] ,Phone = ['" & phone & "'] ,JobPosition = ['" & _ posbox.Text & "'] ,JobStat = ['" & genId & _ "'] WHERE SID='" & id.Text & "'")
Teme64 @ Windows Developer Blog
![]() |
Similar Threads
- Auto Update and manual update fails on XP SP2 Home Edition (Windows NT / 2000 / XP)
- How can I update my access database via VB.net using this code (VB.NET)
- gridview update error (ASP.NET)
- UPDATE query problem (ASP.NET)
- oleDbCommand - Update (ASP.NET)
- ADO.NET question modification. (VB.NET)
- how do i update to Access db? (C#)
- C# Command Line Application (C#)
- ASP.NET / C# Dynamic Control (ASP.NET)
- Auto timedate update (Computer Science)
Other Threads in the VB.NET Forum
- Previous Thread: How Could I Do Nested Datagridview in vb.net
- Next Thread: Portable Database
| Thread Tools | Search this Thread |
.net .net2005 30minutes 2005 2008 access account arithmetic array basic binary bing button buttons c# center check code combobox component connectionstring convert crystalreport data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dropdownlist excel file-dialog folder ftp generatetags google gridview hardcopy image images inline insert intel internet listview mobile monitor ms net networking output passingparameters peertopeervideostreaming picturebox picturebox1 plugin port print problem problemwithinstallation project reports" save savedialog searchbox searchvb.net select serial server soap sql string table tcp text textbox timer toolbox trim update updown user usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web wpf





