Imports System.Data.OleDb

Public Class Form3

    Dim cmd As New OleDbCommand
    Dim rdr As OleDbDataReader
    Dim strmsg As String
    Dim db As New mydb1
    Dim da As New OleDbDataAdapter
    Dim dset As New DataSet

    Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        db.dbconnection()

        strmsg = "select Class from Week"

        cmd = db.dbcommand(strmsg)


        rdr = cmd.ExecuteReader
        'While rdr.Read
        'ComClass1.Items.Add(rdr.Item("class"))

        'End While
        rdr.Close()
    EndSub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles  ComboBox1.SelectedIndexChanged
        cmd.CommandText = "select * from Week where Nme = '"& ComboBox1.Text.ToString &"' "
        rdr = cmd.ExecuteReader
        rdr.Read()
        txtClass.Text = rdr.Item("Class")

        rdr.Close()
    EndSub

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        cmd = db.dbcommand("insert into Week(Nme,Score,Class) values(Default,'"& Val(txtScore.Text) &"',Default ) where Nme = '"& ComboBox1.Text.ToString &"'")
        cmd.ExecuteNonQuery()
        Me.Hide()
        'cmd.Dispose()

    EndSub
EndClass

following are the screenshots of error and my table

Edited 3 Years Ago by Reverend Jim: fixed formatting

You have a few problems to clear up before we can answer your question.

  1. You need to use the Code tool to insert code or you lose all formatting (I fixed it up for you this time)
  2. You did not attach any screenshots
  3. Your question is confusing

Please provide more detail.

By the way, you don't need to use ToString on something that is already a string. Just use

ComboBox1.Text

Edited 3 Years Ago by Reverend Jim

In the editor's toolbar, click "Files". You should get some "Choose" buttons. If you select a file, it will be automatically uploaded and attached.

If you are not going to provide full information then you are not going to get help. For example, what is

 Dim db As New mydb1

I presume mydb1 is a user written class but there is no way of knowing what this is because you haven't provided the code. We don't know what your database looks like or even what type of database it is because, again, you seem more interested in playing twenty questions than in getting an answer.

This article has been dead for over six months. Start a new discussion instead.