| | |
help in my linkin....
Please support our VB.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
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 2008 access add application arithmetic array assignment basic beginner box button buttons click code combo component connectionstring convert cpu cuesent data database databasesearch datagrid datagridview datetimepicker design designer dissertation dissertations dissertationthesis dosconsolevb.net editvb.net exists firewall folder forms html image images isnumericfuntioncall listview math mobile module mssqlbackend mysql navigate number opacity open peertopeervideostreaming picturebox1 picturebox2 port print printpreview problemwithinstallation project record regex reports" reuse right-to-left savedialog serial settings socket sqldatbase sqlserver storedprocedure string temp textbox timer txttoxmlconverter updown useraccounts usercontol usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vbnet view vista visual visualbasic visualbasic.net visualstudio visualstudio.net web wpf wrapingcode xml





