vbinuyasha
Member
- Joined
- Feb 18, 2006
- Messages
- 8
- Programming Experience
- Beginner
ok it nolonger gives me an error but it doesn't add anything to the db am i missing something here?
please can some one help me beside a doctor and a padded room!!!!!!
VB.NET:
[SIZE=2][COLOR=#0000ff]
Private[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] btnAdd_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] btnAdd.Click
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] objRow [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] DataRow
[/SIZE][SIZE=2][COLOR=#008000]'Create a new DataRow object for this table
[/COLOR][/SIZE][SIZE=2]objRow = ds.Tables("CarInfo").NewRow()
[/SIZE][SIZE=2][COLOR=#008000]'Edit Each Field value
[/COLOR][/SIZE][SIZE=2]objRow.Item("Make") = txtmake.Text
objRow.Item("Model") = txtmodel.Text
objRow.Item("Color") = txtcolor.Text
objRow.Item("Year") = txtyear.Text
[/SIZE][SIZE=2][COLOR=#0000ff]Try
[/COLOR][/SIZE][SIZE=2]cn = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Alex\My Documents\Visual Studio Projects\WindowsApplication3\Cars.mdb;")
cn.Open()
str = "Insert into CarInfo values(" & txtmake.Text & ",'" & txtmodel.Text & "','" & txtcolor.Text & "','" & txtyear.Text & "')"
[/SIZE][SIZE=2][COLOR=#008000]'string stores the command and CInt is used to convert number to string
[/COLOR][/SIZE][SIZE=2]cmd = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] OleDbCommand
icount = cmd.ExecuteNonQuery
MessageBox.Show(icount)
[/SIZE][SIZE=2][COLOR=#0000ff]Catch
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Try
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]'displays number of records inserted
[/COLOR][/SIZE][SIZE=2]cn.Close()
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE]
please can some one help me beside a doctor and a padded room!!!!!!