| | |
help in my linkin....
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2008
Posts: 10
Reputation:
Solved Threads: 0
i have written a vb.net coding for linkin my vb interface to my access database...its all the same....but some linking codes i wrote work,for other forms,but sum don work...
this is 1...its a form to add staff in my system
Thats my code above, my access fields are all text....coz i always get errors if i use other types.....can sum1 plz help me....i also noticed there are numerous ways to use ole.db to add to database....can sum1 tel me waths wrong??.....thank you....
this is 1...its a form to add staff in my system
vb Syntax (Toggle Plain Text)
Imports System.Data Imports System.Data.OleDb Public Class Form1 Dim ds As New DataSet Dim data As New OleDbDataAdapter Dim conn As New OleDbConnection Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\Group Project\Staff\Staff\bin\Debug\Blindz.mdb;User Id=;Password=;" data.SelectCommand = New OleDbCommand("SELECT * FROM Staff") data.SelectCommand.Connection = conn data.Fill(ds) data.InsertCommand = New OleDbCommand("INSERT INTO Staff(StaffName,BirthDate,Gender,Address,Phone,Position,StaffID,SystemPassword) VALUES(@StaffName,@BirthDate,@Gender,@Address,@Phone,@Position,@StaffID,@SystemPassword)") data.InsertCommand.Connection = conn data.InsertCommand.Parameters.Add("@StaffName", OleDbType.VarChar, 40, "StaffName") data.InsertCommand.Parameters.Add("@BirthDate", OleDbType.VarChar, 40, "BirthDate") data.InsertCommand.Parameters.Add("@Gender", OleDbType.VarChar, 40, "Gender") data.InsertCommand.Parameters.Add("@Address", OleDbType.VarChar, 40, "Address") data.InsertCommand.Parameters.Add("@Phone", OleDbType.VarChar, 40, "Phone") data.InsertCommand.Parameters.Add("@Pos", OleDbType.VarChar, 40, "Pos") data.InsertCommand.Parameters.Add("@StaffID", OleDbType.VarChar, 40, "StaffID") data.InsertCommand.Parameters.Add("@SysPassword", OleDbType.VarChar, 40, "SysPassword") End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim dr As DataRow dr = ds.Tables(0).NewRow() 'Gets a reference to a new row. dr("StaffName") = namebox.Text dr("BirthDate") = datebox.Value dr("Gender") = genbox.Text dr("Address") = addbox.Text dr("Phone") = phonebox.Text dr("Pos") = posbox.Text dr("StaffID") = id.Text dr("SysPassword") = syspass.Text ds.Tables(0).Rows.Add(dr) data.Update(ds) ds.AcceptChanges() End Sub End Class
Thats my code above, my access fields are all text....coz i always get errors if i use other types.....can sum1 plz help me....i also noticed there are numerous ways to use ole.db to add to database....can sum1 tel me waths wrong??.....thank you....
Last edited by Tekmaven; Oct 4th, 2008 at 7:06 pm. Reason: Code tags
![]() |
Similar Threads
- What kind of music (Geeks' Lounge)
- Who do you like (Geeks' Lounge)
- Tell us about yourself! (Community Introductions)
- Top 10 Songs (Geeks' Lounge)
Other Threads in the VB.NET Forum
- Previous Thread: Date and oledb
- Next Thread: using generic procedures
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2005 2008 access account arithmetic array basic binary bing button buttons center check code combobox component connectionstring crystalreport data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dropdownlist excel file-dialog folder ftp generatetags google gridview hardcopy image images insert intel internet listview login math mobile monitor ms navigate net networking opacity output passingparameters peertopeervideostreaming picturebox picturebox1 port print problem problemwithinstallation project reports" save savedialog searchbox searchvb.net select serial soap string table tcp text textbox timer toolbox trim update updown user usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web wpf





