05-03-2012, 11:37 PM
Join Date: May 2008
vb .net database error
Hey guys, you have finally convinced me to switch to .net after 10+ years of vb6 I have made the switch. I have been trying to get the database sample to work. I have been unable to figure it out. I posted my code below, but something isn't working right and I cant figure it out. Please review my code if you have a chance and let me know what I am doing wrong. I am having a really hard time understanding the dataset,dataadapter, etc etc. I am looking for some help and maybe some working code samples that I can play with to try to teach myself. I keep getting this error in the sample : Value of type 'WindowsApplication1.testDataSetTableAdapters.studentsTableAdapter' cannot be converted to 'System.Data.OleDb.OleDbDataAdapter'
Thanks for your help! matt
Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'student_data_DataSet.students' table. You can move, or remove it, as needed.
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
' Setup a command builder so that we can talk to the data adapter.
Dim commandBuilder As New OleDb.OleDbCommandBuilder(StudentsTableAdapter)
Dim newRow As DataRow
newRow = student_data_DataSet.Tables("students").NewRow
' Add columns for each item.
newRow.Item("Student Name") = TextBox1.Text
' Add the new row to the table in the student_data_DataSet.
' Write the changes to the database.
MessageBox.Show("New student added to the database.")
These are the lines that are throwing the errors
"Dim commandBuilder As New OleDb.OleDbCommandBuilder(StudentsTableAdapter)"
both are throwing the same error. I took some quick screen shots to show : http://imgur.com/a/dddHP