Dim oledbcom As New OleDb.OleDbCommand
oledbcom.CommandText = "Select ID from Customer where Company = ?"
oledbcom.Connection = oledbcon
Dim oledbparam As OleDb.OleDbParameter = _
oledbcom.Parameters.Add("@Company", OleDb.OleDbType.VarChar, 50)
oledbparam.Value = frmNewCompany.txtCompName.Text.Trim
Dim oledbreader As OleDb.OleDbDataReader = oledbcom.ExecuteReader
Dim id As Integer
While oledbreader.Read
id = oledbreader.GetInt32(0)
End While
'end of fetch
'insert the colour name in colour table
Dim oledbcom1 As New OleDb.OleDbCommand
oledbcom1.CommandText = ("INSERT INTO Colour (ID, [Colour Name]) values (?,?)")
oledbcom1.Connection = oledbcon
Dim oledbparam1 As OleDb.OleDbParameter = _
oledbcom1.Parameters.Add("@ID", OleDb.OleDbType.VarChar)
oledbparam1.Value = id
oledbcom1.Parameters.Add("@Colour", OleDb.OleDbType.VarChar, 15)
oledbparam1.Value = txtColourName.Text.Trim
oledbcom1.ExecuteNonQuery()