| | |
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 |
Tag cloud for VB.NET
.net .net2008 2005 2008 access account application array arrays basic beginner browser button buttons center checkbox client code convert cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic eclipse excel fade filter forms ftp generatetags gridview html images inline input insert intel internet lib listview mobile monitor net objects open panel passingparameters pdf picturebox port position print printing problem read remove save searchvb.net select serial settings shutdown soap sorting sqlserver survey table temperature textbox timer timespan transparency trim update user validation vb vb.net vb.netformclosing()eventpictureboxmessagebox vb2008 vba vbnet visual visualbasic visualbasic.net visualstudio.net visualstudio2008 web webbrowser winforms wpf wrapingcode year





