G
Guest
I first wrote a simple program filling a bunch of
comboboxes, filling a textbox, a doing a couple other
things. It worked fine, everytime. All the code of this
project is at the end of this post.
Then I tried to take it a step further. That step was to
check all the comboboxes, a couple text boxes to make
sure they had proper contents and selections. Then I
would add a new row to a different table in the database
by using the values of the comboboxes, textboxes and
datetimepicker.value. After I put in that code,
something strange happened. The connection in the
subroutines that filled the comboboxes stopped working.
I'd get the following error message.
An unhandled exception of
type 'System.Data.OleDb.OleDbException' occurred in
system.data.dll
Additional information: No error information available:
DB_SEC_E_AUTH_FAILED(0x80040E4D).
The first thing I tried was commenting out the
clsDChor.NewTopic()
statement in the Private Sub btnSaveTabGeneral_Click
I didn't expect that to work, and it didn't. So I
uncommented it.
The second thing was to place a messagebox statement in
the subfillbox in clsdatachor.vb, to see if the first
attempt to fill a combobox caused the exception, or
whether it was a particular combobox caused it.
The first combobox was named and then the
An unhandled exception of
type 'System.Data.OleDb.OleDbException' occurred in
system.data.dll
Additional information: No error information available:
DB_SEC_E_AUTH_FAILED(0x80040E4D).
exception occured, so no particular combobox was the
culprit. I deleted the msgbox.
The next thing was to comment out the function newtopic
and addtopic in clsdatachor, since filling the list boxes
worked fine before I put these in. Of course I again
commented out the call to the addtopic method.
Nope, didn't work. I left them commented out for the
moment.
Next I created a listbox, put in the statement to fill
it, and called that in form_load.
Didn't work. Deleted the listbox and statement calling it.
Next I tried filling a combobox with a function instead
of a sub. I knew this was grasping at straws, but it
only took a minute or so. Here is the function in
DataChor:
Friend Function AFillBox(ByRef lst As ComboBox, ByVal
strSQL As String, ByVal tbl As String) As Boolean
Dim cn As New OleDbConnection(gstrConn)
cn.Open()
Dim cmd As New OleDbCommand(strSQL, cn)
Dim da As OleDbDataAdapter = New OleDbDataAdapter
da.SelectCommand = cmd
' Fill the DataSet
Dim ds As DataSet = New DataSet
da.Fill(ds, tbl)
Dim tbl1 As DataTable = ds.Tables(0)
Dim row As DataRow = tbl1.Rows(0)
' Bind the DataSet to the DataList
lst.ValueMember = ds.Tables(tbl).Columns
(0).ColumnName
lst.DisplayMember = ds.Tables(tbl).Columns
(1).ColumnName
lst.DataSource = ds.Tables(tbl)
cn.Close()
End Function
As expected, this failed with the same error
message. I deleted the function and the statement
calling it.
The only other thing I added before the comboboxes were
filled was the code behind the save button in the form.
So I commented out the content of the event procedure.
Nope, same error message. Can anybody tell me why cn.open
() failed?
As stated above, the entire code follows.
thanks,
dennist
Imports System.io
Imports System.Data
Imports System.Data.OleDb
Public Class frmTopicFromStart
Inherits System.Windows.Forms.Form
Private mbSaveTabGeneral As Boolean = False
Private mbSaveTabAuthors As Boolean = False
Private mbSaveTabKeywords As Boolean = False
Private mbSaveTabConcepts As Boolean = False
Property SaveTabConcepts() As Boolean
Get
Return mbSaveTabConcepts
End Get
Set(ByVal Value As Boolean)
mbSaveTabConcepts = Value
End Set
End Property
Property SaveTabKeywords() As Boolean
Get
Return mbSaveTabKeywords
End Get
Set(ByVal Value As Boolean)
mbSaveTabKeywords = Value
End Set
End Property
Property SaveTabGeneral() As Boolean
Get
Return mbSaveTabGeneral
End Get
Set(ByVal Value As Boolean)
mbSaveTabGeneral = Value
End Set
End Property
Property SaveTabAuthors() As Boolean
Get
Return mbSaveTabAuthors
End Get
Set(ByVal Value As Boolean)
mbSaveTabAuthors = Value
End Set
End Property
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form
Designer.
InitializeComponent()
'Add any initialization after the
InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component
list.
Protected Overloads Overrides Sub Dispose(ByVal
disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the
Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents TabControl1 As
System.Windows.Forms.TabControl
Friend WithEvents TabPage1 As
System.Windows.Forms.TabPage
Friend WithEvents btnSaveTabGeneral As
System.Windows.Forms.Button
Friend WithEvents txtID As
System.Windows.Forms.TextBox
Friend WithEvents lblID As System.Windows.Forms.Label
Friend WithEvents lblParentID As
System.Windows.Forms.Label
Friend WithEvents txtParentID As
System.Windows.Forms.TextBox
Friend WithEvents lblTopicTitle As
System.Windows.Forms.Label
Friend WithEvents txtTopicTitle As
System.Windows.Forms.TextBox
Friend WithEvents btnOpenFile As
System.Windows.Forms.Button
Friend WithEvents btnDateTransfer As
System.Windows.Forms.Button
Friend WithEvents btnTopicTitle As
System.Windows.Forms.Button
Friend WithEvents lbltxtTextGeneral As
System.Windows.Forms.Label
Friend WithEvents txtTextGeneral As
System.Windows.Forms.TextBox
Friend WithEvents dtp1 As
System.Windows.Forms.DateTimePicker
Friend WithEvents lblDate As
System.Windows.Forms.Label
Friend WithEvents lblDateTypes As
System.Windows.Forms.Label
Friend WithEvents cboDateType As
System.Windows.Forms.ComboBox
Friend WithEvents lblPOV As System.Windows.Forms.Label
Friend WithEvents cboPOV As
System.Windows.Forms.ComboBox
Friend WithEvents lblPermission As
System.Windows.Forms.Label
Friend WithEvents lblPublications As
System.Windows.Forms.Label
Friend WithEvents lblTopicIssuer As
System.Windows.Forms.Label
Friend WithEvents cboPublications As
System.Windows.Forms.ComboBox
Friend WithEvents txtPermission As
System.Windows.Forms.TextBox
Friend WithEvents cboTopicIssuers As
System.Windows.Forms.ComboBox
Friend WithEvents TabPage2 As
System.Windows.Forms.TabPage
Friend WithEvents txtTextAuthors As
System.Windows.Forms.TextBox
Friend WithEvents lblTopicText As
System.Windows.Forms.Label
Friend WithEvents btnSaveTabAuthors As
System.Windows.Forms.Button
Friend WithEvents lblAuthors As
System.Windows.Forms.Label
Friend WithEvents lstAuthors As
System.Windows.Forms.ListBox
Friend WithEvents TabPage3 As
System.Windows.Forms.TabPage
Friend WithEvents ListBox1 As
System.Windows.Forms.ListBox
Friend WithEvents btnQuit As
System.Windows.Forms.Button
Friend WithEvents OFD1 As
System.Windows.Forms.OpenFileDialog
<System.Diagnostics.DebuggerStepThrough()> Private
Sub InitializeComponent()
Me.TabControl1 = New
System.Windows.Forms.TabControl
Me.TabPage1 = New System.Windows.Forms.TabPage
Me.btnSaveTabGeneral = New
System.Windows.Forms.Button
Me.txtID = New System.Windows.Forms.TextBox
Me.lblID = New System.Windows.Forms.Label
Me.lblParentID = New System.Windows.Forms.Label
Me.txtParentID = New System.Windows.Forms.TextBox
Me.lblTopicTitle = New System.Windows.Forms.Label
Me.txtTopicTitle = New
System.Windows.Forms.TextBox
Me.btnOpenFile = New System.Windows.Forms.Button
Me.btnDateTransfer = New
System.Windows.Forms.Button
Me.btnTopicTitle = New System.Windows.Forms.Button
Me.lbltxtTextGeneral = New
System.Windows.Forms.Label
Me.txtTextGeneral = New
System.Windows.Forms.TextBox
Me.dtp1 = New System.Windows.Forms.DateTimePicker
Me.lblDate = New System.Windows.Forms.Label
Me.lblDateTypes = New System.Windows.Forms.Label
Me.cboDateType = New System.Windows.Forms.ComboBox
Me.lblPOV = New System.Windows.Forms.Label
Me.cboPOV = New System.Windows.Forms.ComboBox
Me.lblPermission = New System.Windows.Forms.Label
Me.lblPublications = New
System.Windows.Forms.Label
Me.lblTopicIssuer = New System.Windows.Forms.Label
Me.cboPublications = New
System.Windows.Forms.ComboBox
Me.txtPermission = New
System.Windows.Forms.TextBox
Me.cboTopicIssuers = New
System.Windows.Forms.ComboBox
Me.TabPage2 = New System.Windows.Forms.TabPage
Me.txtTextAuthors = New
System.Windows.Forms.TextBox
Me.lblTopicText = New System.Windows.Forms.Label
Me.btnSaveTabAuthors = New
System.Windows.Forms.Button
Me.lblAuthors = New System.Windows.Forms.Label
Me.lstAuthors = New System.Windows.Forms.ListBox
Me.TabPage3 = New System.Windows.Forms.TabPage
Me.ListBox1 = New System.Windows.Forms.ListBox
Me.btnQuit = New System.Windows.Forms.Button
Me.OFD1 = New System.Windows.Forms.OpenFileDialog
Me.TabControl1.SuspendLayout()
Me.TabPage1.SuspendLayout()
Me.TabPage2.SuspendLayout()
Me.TabPage3.SuspendLayout()
Me.SuspendLayout()
'
'TabControl1
'
Me.TabControl1.Controls.Add(Me.TabPage1)
Me.TabControl1.Controls.Add(Me.TabPage2)
Me.TabControl1.Controls.Add(Me.TabPage3)
Me.TabControl1.Location = New System.Drawing.Point
(24, 32)
Me.TabControl1.Name = "TabControl1"
Me.TabControl1.SelectedIndex = 0
Me.TabControl1.Size = New System.Drawing.Size
(696, 432)
Me.TabControl1.TabIndex = 2
'
'TabPage1
'
Me.TabPage1.Controls.Add(Me.btnSaveTabGeneral)
Me.TabPage1.Controls.Add(Me.txtID)
Me.TabPage1.Controls.Add(Me.lblID)
Me.TabPage1.Controls.Add(Me.lblParentID)
Me.TabPage1.Controls.Add(Me.txtParentID)
Me.TabPage1.Controls.Add(Me.lblTopicTitle)
Me.TabPage1.Controls.Add(Me.txtTopicTitle)
Me.TabPage1.Controls.Add(Me.btnOpenFile)
Me.TabPage1.Controls.Add(Me.btnDateTransfer)
Me.TabPage1.Controls.Add(Me.btnTopicTitle)
Me.TabPage1.Controls.Add(Me.lbltxtTextGeneral)
Me.TabPage1.Controls.Add(Me.txtTextGeneral)
Me.TabPage1.Controls.Add(Me.dtp1)
Me.TabPage1.Controls.Add(Me.lblDate)
Me.TabPage1.Controls.Add(Me.lblDateTypes)
Me.TabPage1.Controls.Add(Me.cboDateType)
Me.TabPage1.Controls.Add(Me.lblPOV)
Me.TabPage1.Controls.Add(Me.cboPOV)
Me.TabPage1.Controls.Add(Me.lblPermission)
Me.TabPage1.Controls.Add(Me.lblPublications)
Me.TabPage1.Controls.Add(Me.lblTopicIssuer)
Me.TabPage1.Controls.Add(Me.cboPublications)
Me.TabPage1.Controls.Add(Me.txtPermission)
Me.TabPage1.Controls.Add(Me.cboTopicIssuers)
Me.TabPage1.Location = New System.Drawing.Point
(4, 22)
Me.TabPage1.Name = "TabPage1"
Me.TabPage1.Size = New System.Drawing.Size(688,
406)
Me.TabPage1.TabIndex = 0
Me.TabPage1.Text = "General"
'
'btnSaveTabGeneral
'
Me.btnSaveTabGeneral.Location = New
System.Drawing.Point(576, 320)
Me.btnSaveTabGeneral.Name = "btnSaveTabGeneral"
Me.btnSaveTabGeneral.Size = New
System.Drawing.Size(88, 56)
Me.btnSaveTabGeneral.TabIndex = 24
Me.btnSaveTabGeneral.Text = "Save"
'
'txtID
'
Me.txtID.Location = New System.Drawing.Point(536,
264)
Me.txtID.Name = "txtID"
Me.txtID.ReadOnly = True
Me.txtID.Size = New System.Drawing.Size(128, 20)
Me.txtID.TabIndex = 23
Me.txtID.Text = ""
'
'lblID
'
Me.lblID.Location = New System.Drawing.Point(536,
248)
Me.lblID.Name = "lblID"
Me.lblID.Size = New System.Drawing.Size(104, 16)
Me.lblID.TabIndex = 22
Me.lblID.Text = "ID"
'
'lblParentID
'
Me.lblParentID.Location = New System.Drawing.Point
(536, 184)
Me.lblParentID.Name = "lblParentID"
Me.lblParentID.Size = New System.Drawing.Size
(112, 16)
Me.lblParentID.TabIndex = 21
Me.lblParentID.Text = "ParentID"
'
'txtParentID
'
Me.txtParentID.Location = New System.Drawing.Point
(536, 200)
Me.txtParentID.Name = "txtParentID"
Me.txtParentID.ReadOnly = True
Me.txtParentID.Size = New System.Drawing.Size
(128, 20)
Me.txtParentID.TabIndex = 20
Me.txtParentID.Text = "0"
'
'lblTopicTitle
'
Me.lblTopicTitle.Location = New
System.Drawing.Point(536, 64)
Me.lblTopicTitle.Name = "lblTopicTitle"
Me.lblTopicTitle.Size = New System.Drawing.Size
(80, 16)
Me.lblTopicTitle.TabIndex = 19
Me.lblTopicTitle.Text = "Topic Title"
'
'txtTopicTitle
'
Me.txtTopicTitle.Location = New
System.Drawing.Point(536, 80)
Me.txtTopicTitle.Multiline = True
Me.txtTopicTitle.Name = "txtTopicTitle"
Me.txtTopicTitle.ScrollBars =
System.Windows.Forms.ScrollBars.Vertical
Me.txtTopicTitle.Size = New System.Drawing.Size
(128, 80)
Me.txtTopicTitle.TabIndex = 18
Me.txtTopicTitle.Text = ""
'
'btnOpenFile
'
Me.btnOpenFile.Location = New System.Drawing.Point
(424, 48)
Me.btnOpenFile.Name = "btnOpenFile"
Me.btnOpenFile.Size = New System.Drawing.Size(72,
32)
Me.btnOpenFile.TabIndex = 17
Me.btnOpenFile.Text = "Open File"
'
'btnDateTransfer
'
Me.btnDateTransfer.Location = New
System.Drawing.Point(328, 48)
Me.btnDateTransfer.Name = "btnDateTransfer"
Me.btnDateTransfer.Size = New System.Drawing.Size
(88, 32)
Me.btnDateTransfer.TabIndex = 16
Me.btnDateTransfer.Text = "Date Transfer"
'
'btnTopicTitle
'
Me.btnTopicTitle.Location = New
System.Drawing.Point(256, 48)
Me.btnTopicTitle.Name = "btnTopicTitle"
Me.btnTopicTitle.Size = New System.Drawing.Size
(64, 32)
Me.btnTopicTitle.TabIndex = 15
Me.btnTopicTitle.Text = "Topic Title"
'
'lbltxtTextGeneral
'
Me.lbltxtTextGeneral.Location = New
System.Drawing.Point(192, 64)
Me.lbltxtTextGeneral.Name = "lbltxtTextGeneral"
Me.lbltxtTextGeneral.Size = New
System.Drawing.Size(64, 16)
Me.lbltxtTextGeneral.TabIndex = 14
Me.lbltxtTextGeneral.Text = "Topic Text"
'
'txtTextGeneral
'
Me.txtTextGeneral.Location = New
System.Drawing.Point(192, 80)
Me.txtTextGeneral.Multiline = True
Me.txtTextGeneral.Name = "txtTextGeneral"
Me.txtTextGeneral.ScrollBars =
System.Windows.Forms.ScrollBars.Vertical
Me.txtTextGeneral.Size = New System.Drawing.Size
(304, 296)
Me.txtTextGeneral.TabIndex = 13
Me.txtTextGeneral.Text = ""
'
'dtp1
'
Me.dtp1.Format =
System.Windows.Forms.DateTimePickerFormat.Short
Me.dtp1.Location = New System.Drawing.Point(24,
360)
Me.dtp1.Name = "dtp1"
Me.dtp1.Size = New System.Drawing.Size(128, 20)
Me.dtp1.TabIndex = 12
'
'lblDate
'
Me.lblDate.Location = New System.Drawing.Point
(24, 344)
Me.lblDate.Name = "lblDate"
Me.lblDate.Size = New System.Drawing.Size(80, 16)
Me.lblDate.TabIndex = 11
Me.lblDate.Text = "Date"
'
'lblDateTypes
'
Me.lblDateTypes.Location = New
System.Drawing.Point(24, 288)
Me.lblDateTypes.Name = "lblDateTypes"
Me.lblDateTypes.Size = New System.Drawing.Size
(64, 16)
Me.lblDateTypes.TabIndex = 9
Me.lblDateTypes.Text = "DateTypes"
'
'cboDateType
'
Me.cboDateType.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList
Me.cboDateType.DropDownWidth = 192
Me.cboDateType.Location = New System.Drawing.Point
(24, 304)
Me.cboDateType.Name = "cboDateType"
Me.cboDateType.Size = New System.Drawing.Size
(128, 21)
Me.cboDateType.TabIndex = 8
'
'lblPOV
'
Me.lblPOV.Location = New System.Drawing.Point(24,
176)
Me.lblPOV.Name = "lblPOV"
Me.lblPOV.Size = New System.Drawing.Size(88, 16)
Me.lblPOV.TabIndex = 7
Me.lblPOV.Text = "Points of View"
'
'cboPOV
'
Me.cboPOV.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList
Me.cboPOV.DropDownWidth = 192
Me.cboPOV.Location = New System.Drawing.Point(24,
192)
Me.cboPOV.Name = "cboPOV"
Me.cboPOV.Size = New System.Drawing.Size(128, 21)
Me.cboPOV.TabIndex = 6
'
'lblPermission
'
Me.lblPermission.Location = New
System.Drawing.Point(24, 232)
Me.lblPermission.Name = "lblPermission"
Me.lblPermission.Size = New System.Drawing.Size
(80, 16)
Me.lblPermission.TabIndex = 5
Me.lblPermission.Text = "Permission"
'
'lblPublications
'
Me.lblPublications.Location = New
System.Drawing.Point(24, 120)
Me.lblPublications.Name = "lblPublications"
Me.lblPublications.Size = New System.Drawing.Size
(100, 16)
Me.lblPublications.TabIndex = 4
Me.lblPublications.Text = "Publications"
'
'lblTopicIssuer
'
Me.lblTopicIssuer.Location = New
System.Drawing.Point(24, 64)
Me.lblTopicIssuer.Name = "lblTopicIssuer"
Me.lblTopicIssuer.Size = New System.Drawing.Size
(100, 16)
Me.lblTopicIssuer.TabIndex = 3
Me.lblTopicIssuer.Text = "TopicIssuers"
'
'cboPublications
'
Me.cboPublications.DropDownWidth = 192
Me.cboPublications.Location = New
System.Drawing.Point(24, 136)
Me.cboPublications.Name = "cboPublications"
Me.cboPublications.Size = New System.Drawing.Size
(128, 21)
Me.cboPublications.TabIndex = 2
'
'txtPermission
'
Me.txtPermission.BackColor =
System.Drawing.SystemColors.Control
Me.txtPermission.Location = New
System.Drawing.Point(24, 248)
Me.txtPermission.Name = "txtPermission"
Me.txtPermission.ReadOnly = True
Me.txtPermission.Size = New System.Drawing.Size
(128, 20)
Me.txtPermission.TabIndex = 1
Me.txtPermission.Text = "6"
'
'cboTopicIssuers
'
Me.cboTopicIssuers.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList
Me.cboTopicIssuers.DropDownWidth = 192
Me.cboTopicIssuers.Location = New
System.Drawing.Point(24, 80)
Me.cboTopicIssuers.Name = "cboTopicIssuers"
Me.cboTopicIssuers.Size = New System.Drawing.Size
(128, 21)
Me.cboTopicIssuers.TabIndex = 0
'
'TabPage2
'
Me.TabPage2.Controls.Add(Me.txtTextAuthors)
Me.TabPage2.Controls.Add(Me.lblTopicText)
Me.TabPage2.Controls.Add(Me.btnSaveTabAuthors)
Me.TabPage2.Controls.Add(Me.lblAuthors)
Me.TabPage2.Controls.Add(Me.lstAuthors)
Me.TabPage2.Location = New System.Drawing.Point
(4, 22)
Me.TabPage2.Name = "TabPage2"
Me.TabPage2.Size = New System.Drawing.Size(688,
406)
Me.TabPage2.TabIndex = 1
Me.TabPage2.Text = "Authors"
Me.TabPage2.Visible = False
'
'txtTextAuthors
'
Me.txtTextAuthors.Location = New
System.Drawing.Point(280, 64)
Me.txtTextAuthors.Multiline = True
Me.txtTextAuthors.Name = "txtTextAuthors"
Me.txtTextAuthors.ReadOnly = True
Me.txtTextAuthors.Size = New System.Drawing.Size
(364, 296)
Me.txtTextAuthors.TabIndex = 4
Me.txtTextAuthors.Text = "TextBox1"
'
'lblTopicText
'
Me.lblTopicText.Location = New
System.Drawing.Point(280, 48)
Me.lblTopicText.Name = "lblTopicText"
Me.lblTopicText.Size = New System.Drawing.Size
(112, 16)
Me.lblTopicText.TabIndex = 3
Me.lblTopicText.Text = "Topic Text"
'
'btnSaveTabAuthors
'
Me.btnSaveTabAuthors.Location = New
System.Drawing.Point(176, 320)
Me.btnSaveTabAuthors.Name = "btnSaveTabAuthors"
Me.btnSaveTabAuthors.Size = New
System.Drawing.Size(64, 40)
Me.btnSaveTabAuthors.TabIndex = 2
Me.btnSaveTabAuthors.Text = "Save"
'
'lblAuthors
'
Me.lblAuthors.Location = New System.Drawing.Point
(40, 48)
Me.lblAuthors.Name = "lblAuthors"
Me.lblAuthors.Size = New System.Drawing.Size(112,
16)
Me.lblAuthors.TabIndex = 1
Me.lblAuthors.Text = "Authors"
'
'lstAuthors
'
Me.lstAuthors.Location = New System.Drawing.Point
(40, 64)
Me.lstAuthors.Name = "lstAuthors"
Me.lstAuthors.Size = New System.Drawing.Size(200,
212)
Me.lstAuthors.TabIndex = 0
'
'TabPage3
'
Me.TabPage3.Controls.Add(Me.ListBox1)
Me.TabPage3.Location = New System.Drawing.Point
(4, 22)
Me.TabPage3.Name = "TabPage3"
Me.TabPage3.Size = New System.Drawing.Size(688,
406)
Me.TabPage3.TabIndex = 2
Me.TabPage3.Text = "Keywords"
Me.TabPage3.Visible = False
'
'ListBox1
'
Me.ListBox1.Location = New System.Drawing.Point
(208, 56)
Me.ListBox1.Name = "ListBox1"
Me.ListBox1.Size = New System.Drawing.Size(280,
251)
Me.ListBox1.TabIndex = 0
'
'btnQuit
'
Me.btnQuit.Location = New System.Drawing.Point
(632, 496)
Me.btnQuit.Name = "btnQuit"
Me.btnQuit.Size = New System.Drawing.Size(88, 32)
Me.btnQuit.TabIndex = 3
Me.btnQuit.Text = "Quit"
'
'frmTopicFromStart
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5,
13)
Me.ClientSize = New System.Drawing.Size(744, 550)
Me.Controls.Add(Me.btnQuit)
Me.Controls.Add(Me.TabControl1)
Me.Name = "frmTopicFromStart"
Me.Text = "Form1"
Me.TabControl1.ResumeLayout(False)
Me.TabPage1.ResumeLayout(False)
Me.TabPage2.ResumeLayout(False)
Me.TabPage3.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub togethelp()
Dim str1 As String
'str1.
'IsDate()
End Sub
Private Sub btnQuit_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnQuit.Click
End
End Sub
Private Sub frmtopicfromstart_Load(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
Dim clsDChor As New clsDataChor
txtTextGeneral.Text = ""
clsDChor.FillBox(cboTopicIssuers, "SELECT
TopicIssuers.ID, TopicIssuers.Issuer FROM TopicIssuers
ORDER BY TopicIssuers.Issuer;", "TopicIssuers")
clsDChor.FillBox(cboPublications, "SELECT
Publications.ID, Publications.Publication FROM
Publications ORDER BY
Publications.Publication;", "Publications")
clsDChor.FillBox(cboPOV, "SELECT PointsOfView.ID,
PointsOfView.PointOfView FROM PointsOfView ORDER BY
PointsOfView.PointOfView;", "PointsOfView")
clsDChor.FillBox(cboDateType, "SELECT
DateType.ID, DateType.DateType FROM DateType ORDER BY
DateType.DateType;", "DateType")
'Dim strDate As String = "05/22/2003"
'If IsDate(strDate) Then
' dtp1.Value = strDate
'End If
End Sub
Private Sub TabControl1_SelectedIndexChanged(ByVal
sender As Object, ByVal e As System.EventArgs) Handles
TabControl1.SelectedIndexChanged
'MsgBox(cboCustomers.SelectedIndex.ToString)
If cboTopicIssuers.SelectedIndex >= 0 Then
If txtTopicTitle.Text = "" Then
TabControl1.SelectedTab = TabPage1
End If
End If
End Sub
Private Sub TabPage1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
TabPage1.Click
End Sub
Private Sub cboTopicIssuers_SelectedIndexChanged
(ByVal sender As Object, ByVal e As System.EventArgs)
Handles cboTopicIssuers.SelectedIndexChanged
'MsgBox(cboTopicIssuers.SelectedIndex)
End Sub
Private Sub btnTopicTitle_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnTopicTitle.Click
' Declares an IDataObject to hold the data
returned from the clipboard.
' Retrieves the data from the clipboard.
Clipboard.SetDataObject
(txtTextGeneral.SelectedText, True)
'MsgBox("btntopictitle " &
txtTextGeneral.SelectedText)
Dim iData As IDataObject = Clipboard.GetDataObject
()
Dim str1 As String
' Determines whether the data is in a format you
can use.
If txtTextGeneral.SelectedText = "" Then
MsgBox("No text is selected.")
Exit Sub
End If
If iData.GetDataPresent(DataFormats.Text) Then
str1 = CType(iData.GetData(DataFormats.Text),
String)
'MsgBox(str1)
'If str1.Length = 0 Then
' MsgBox("There is no text in the
clipboard.")
' Exit Sub
'End If
' Yes it is, so display it in a text box.
txtTopicTitle.Text = CType(iData.GetData
(DataFormats.Text), String)
Else
' No it is not.
MsgBox("The clipboard contained something
other than text")
Exit Sub
End If
End Sub
Private Sub txtTextGeneral_TextChanged(ByVal sender
As System.Object, ByVal e As System.EventArgs) Handles
txtTextGeneral.TextChanged
End Sub
Private Sub txtTextGeneral_LostFocus(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
txtTextGeneral.LostFocus
'' Takes the selected text from a text box and
puts it on the clipboard.
'txtTopicTitle.Text = "Leave" 'see leave
'MsgBox("Leave")
'If txtTextGeneral.SelectedText <> "" Then
' Clipboard.SetDataObject
(txtTextGeneral.SelectedText, True)
'Else
' MsgBox("No text selected", , "Warning")
' txtTitle.Text = ""
'End If
End Sub
Private Sub btnOpenFile_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnOpenFile.Click
Dim StreamR1 As System.IO.StreamReader
OFD1.Filter = ("text files(*.txt)|*.txt|(Word
files(*.doc)|*.doc")
OFD1.ShowDialog()
If OFD1.FileName <> "" Then
Try 'open file and trap any erros using
handler
StreamR1 = New StreamReader(OFD1.FileName)
txtTextGeneral.Text = StreamR1.ReadToEnd
StreamR1.Close()
txtTextGeneral.Select(0, 0)
Catch
MsgBox("Error opening file." & vbCr
& "Perhaps bad file name", , "Error!")
Finally
txtTextGeneral.Focus()
'MsgBox(txtTextGeneral.SelectedText)
End Try
End If
End Sub
Private Sub btnDateTransfer_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnDateTransfer.Click
' Declares an IDataObject to hold the data
returned from the clipboard.
' Retrieves the data from the clipboard.
Clipboard.SetDataObject
(txtTextGeneral.SelectedText, True)
Dim iData As IDataObject = Clipboard.GetDataObject
()
Dim str1 As String
' Determines whether the data is in a format you
can use.
If txtTextGeneral.SelectedText = "" Then
MsgBox("No text is selected.")
Exit Sub
End If
If iData.GetDataPresent(DataFormats.Text) Then
str1 = CType(iData.GetData(DataFormats.Text),
String)
' Yes it is, so display it in a text box.
If IsDate(str1) Then
dtp1.Value = str1
Else
MsgBox("Selected text was not a date.")
End If
'txtTopicTitle.Text = CType(iData.GetData
(DataFormats.Text), String)
Else
' No it is not.
MsgBox("The clipboard contained something
other than text")
Exit Sub
End If
End Sub
Private Sub txtTextGeneral_Leave(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
txtTextGeneral.Leave
' Takes the selected text from a text box and
puts it on the clipboard.
'txtTopicTitle.Text = "leave" 'only true if hit
control that can accept text
'MsgBox("Leave")
'If txtTextGeneral.SelectedText <> "" Then
' Clipboard.SetDataObject
(txtTextGeneral.SelectedText, True)
'Else
' MsgBox("No text selected", , "Warning")
' txtTitle.Text = ""
'End If
End Sub
Private Sub TabPage2_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
TabPage2.Click
End Sub
Private Sub btnSaveTabGeneral_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnSaveTabGeneral.Click
Dim clsDChor As New clsDataChor
If cboTopicIssuers.SelectedIndex = -1 Then
MsgBox("No Topic Issuer selected.")
cboTopicIssuers.Focus()
Exit Sub
ElseIf cboPublications.SelectedIndex = -1 Then
MsgBox("No Publication selected.")
cboPublications.Focus()
Exit Sub
ElseIf cboPOV.SelectedIndex = -1 Then
MsgBox("No Point of View selected.")
cboPOV.Focus()
Exit Sub
ElseIf txtPermission.Text <> "6" Then
txtPermission.Text = "6"
' Exit Sub
ElseIf cboDateType.SelectedIndex = -1 Then
MsgBox("No Date Type is selected.")
cboDateType.Focus()
Exit Sub
ElseIf Not IsDate(dtp1.Value) Then
MsgBox("The date box does not contain a
date.")
dtp1.Focus()
Exit Sub
ElseIf txtTextGeneral.Text = "" Then
MsgBox("There is no topic text.")
btnOpenFile.Focus()
Exit Sub
ElseIf txtTopicTitle.Text = "" Then
MsgBox("There is no topic title.")
txtTopicTitle.Focus()
Exit Sub
End If
gForm = Me
''
gsTopicText = txtTextGeneral.Text
txtTextGeneral.ReadOnly = True
'txtTopicText.BackColor = &HE0E0E0
txtTextAuthors.Text = gsTopicText
txtTextAuthors.ReadOnly = True
'txtTopicText2.Text = gsTopicText
'txtTopicText2.Locked = True
clsDChor.NewTopic()
'cmdSaveLOG.Enabled = False
'gID = CLng(txtID.Text)
End Sub
End Class
Imports System.Data
Imports System.io
Module modPrimary
Friend gstrConn As String
= "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" 'H:\HasbaraNET\ado.net
tests\adonetTest\HasbaraSample.mdb;"
Public s As String
Public gSelectedFile As String
Public gForm As Form
Public gsTopicText As String
Public gID As Integer
Public gsPath As String
Public Sub Main()
Dim strPath As String
Dim strSubstring As String
Dim intIndexof As Integer
Dim cls1 As New Class1
strPath =
System.Reflection.Assembly.GetExecutingAssembly.Location
intIndexof = strPath.IndexOf("bin")
strSubstring = strPath.Substring(0, intIndexof)
gsPath = strSubstring
ChDir(strSubstring)
gstrConn = gstrConn & "HasbaraSample.mdb;"
SetGlobals()
Application.Run(New frmTopicFromStart)
End Sub
Public Sub SetGlobals()
gSelectedFile = ""
End Sub
End Module
Public Class Class1
Public Shared Function GetFileNameWithoutExtension( _
ByVal path As String _
) As String
End Function
Public Shared Function GetDirectoryName( _
ByVal path As String _
) As String
End Function
End Class
Imports System.Data.oledb
Public Class clsDataChor
Overloads Sub FillBox(ByRef lst As ListBox, ByVal
strSQL As String, ByVal tbl As String)
Dim cn As New OleDbConnection(gstrConn)
cn.Open()
Dim cmd As New OleDbCommand(strSQL, cn)
Dim da As OleDbDataAdapter = New OleDbDataAdapter
da.SelectCommand = cmd
' Fill the DataSet
Dim ds As DataSet = New DataSet
da.Fill(ds, tbl)
Dim tbl1 As DataTable = ds.Tables(0)
Dim row As DataRow = tbl1.Rows(0)
' Bind the DataSet to the DataList
lst.ValueMember = ds.Tables(tbl).Columns
(0).ColumnName
lst.DisplayMember = ds.Tables(tbl).Columns
(1).ColumnName
lst.DataSource = ds.Tables(tbl)
cn.Close()
End Sub
Overloads Sub FillBox(ByRef lst As ComboBox, ByVal
strSQL As String, ByVal tbl As String)
Dim cn As New OleDbConnection(gstrConn)
cn.Open()
Dim cmd As New OleDbCommand(strSQL, cn)
Dim da As OleDbDataAdapter = New OleDbDataAdapter
da.SelectCommand = cmd
' Fill the DataSet
Dim ds As DataSet = New DataSet
da.Fill(ds, tbl)
' Bind the DataSet to the DataList
lst.ValueMember = ds.Tables(tbl).Columns
(0).ColumnName
lst.DisplayMember = ds.Tables(tbl).Columns
(1).ColumnName
lst.DataSource = ds.Tables(tbl)
cn.Close()
End Sub
Friend Function NewTopic() As Boolean
NewTopic = False
Dim cn As New OleDbConnection(gstrConn)
'cn.Open()
MsgBox("after dim cn")
Dim cmd As New OleDbCommand("SELECT * FROM
Topics", cn)
Dim da As OleDbDataAdapter = New OleDbDataAdapter
da.SelectCommand = cmd
MsgBox("before dataset")
' Fill the DataSet
Dim ds As DataSet = New DataSet
ds.DataSetName = "ds1"
'dim tblTopics as ds
da.Fill(ds, "Topics")
cn.Open()
da.FillSchema(ds, SchemaType.Source, "Topics")
ds.WriteXmlSchema("H:\Program Files\Microsoft
Visual Studio .NET 2003\Common7
\IDE\WorkingDirectory.ds.xsl")
MsgBox(ds.Tables.Item(0))
'da..Tables.
'Dim dsTopics As New dsname
'dim tblTopics as ds.
'Dim tblCustomers As Chapter9.CustomersDataTable
= ds.Customers
'Dim rowCustomer As Chapter9.CustomersRow
'rowCustomer = tblCustomers.NewCustomersRow()
'rowCustomer.CustomerID = "ABCDE"
'rowCustomer.CompanyName = "New Company"
'rowCustomer.ContactName = "New Contact"
'rowCustomer.Phone = "(800) 555-1212"
'tblCustomers.AddCustomersRow(rowCustomer)
''Instead of
'Dim rowCustomer As DataRow = tblCustomers.NewRow
()
'rowCustomer("CustomerID") = "ABCDE"
'rowCustomer("CompanyName") = "New Company"
'rowCustomer("ContactName") = "New Contact"
'rowCustomer("Phone") = "(800) 555-1212"
'tblCustomers.Rows.Add(rowCustomer)
Return True
cn.Close()
Dim cn1 As New OleDbConnection(gstrConn)
cn1.Open()
'Dim cmd1 As New OleDbCommand("SELECT * FROM
Topics", cn1)
'Dim da1 As OleDbda1taAda1pter = New
OleDbda1taAda1pter
'da1.SelectCommand = cmd1
'' Fill the da1taSet
'Dim ds1 As da1taSet = New da1taSet
'ds1.da1taSetName = "ds1Name"
''dim tblTopics as ds1
'da1.Fill(ds1, "Topics")
'cn1.Open()
'da1.FillSchema(ds1, SchemaType.Source, "Topics")
'ds1.WriteXmlSchema("gsPath.ds1topics.xsl")
''da1..Tables.
''Dim ds1Topics As New ds1name
''dim tblTopics as ds1.
''Dim tblCustomers As
Chapter9.Customersda1taTable = ds1.Customers
''Dim rowCustomer As Chapter9.CustomersRow
''rowCustomer = tblCustomers.NewCustomersRow()
''rowCustomer.CustomerID = "ABCDE"
''rowCustomer.CompanyName = "New Company"
''rowCustomer.ContactName = "New Contact"
''rowCustomer.Phone = "(800) 555-1212"
''tblCustomers.AddCustomersRow(rowCustomer)
'''Instead of
''Dim rowCustomer As da1taRow =
tblCustomers.NewRow()
''rowCustomer("CustomerID") = "ABCDE"
''rowCustomer("CompanyName") = "New Company"
''rowCustomer("ContactName") = "New Contact"
''rowCustomer("Phone") = "(800) 555-1212"
''tblCustomers.Rows.Add(rowCustomer)
'Return True
'cn1.Close()
End Function
Public Function AddTopic() As Boolean
AddTopic = False
Dim cn As New OleDbConnection(gstrConn)
Try
cn.Open()
Catch e As OleDbException
Dim errorMessages As String
Dim i As Integer
For i = 0 To e.Errors.Count - 1
errorMessages += "Index #" & i.ToString()
& ControlChars.Cr _
& "Message: " & e.Errors
(i).Message & ControlChars.Cr _
& "NativeError: " &
e.Errors(i).NativeError & ControlChars.Cr _
& "Source: " & e.Errors
(i).Source & ControlChars.Cr _
& "SQLState: " & e.Errors
(i).SQLState & ControlChars.Cr
Next i
Dim log As System.Diagnostics.EventLog = New
System.Diagnostics.EventLog
log.Source = "My Application"
log.WriteEntry(errorMessages)
Console.WriteLine("An exception occurred.
Please contact your system administrator.")
End Try
'Dim mySelectQuery As String = "SELECT column1
FROM table1"
'Dim myConnection As New OleDbConnection _
'
("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=")
'Dim myCommand As New OleDbCommand(mySelectQuery,
myConnection)
'Try
' myCommand.Connection.Open()
'Catch e As OleDbException
' Dim errorMessages As String
' Dim i As Integer
' For i = 0 To e.Errors.Count - 1
' errorMessages += "Index #" & i.ToString
() & ControlChars.Cr _
' & "Message: " & e.Errors
(i).Message & ControlChars.Cr _
' & "NativeError: " &
e.Errors(i).NativeError & ControlChars.Cr _
' & "Source: " & e.Errors
(i).Source & ControlChars.Cr _
' & "SQLState: " & e.Errors
(i).SQLState & ControlChars.Cr
' Next i
' Dim log As System.Diagnostics.EventLog = New
System.Diagnostics.EventLog
' log.Source = "My Application"
' log.WriteEntry(errorMessages)
' Console.WriteLine("An exception occurred.
Please contact your system administrator.")
'End Try
'MsgBox(gstrConn)
'Dim strSQL As String = "select * from topics;"
'Dim dsTopics As New DataSet
'dsTopics.DataSetName = "dsTopicsName"
'MsgBox(dsTopics.DataSetName)
''cn.Open()
'Dim daTopics As New OleDbDataAdapter(strSQL, cn)
'daTopics.FillSchema(dsTopics,
SchemaType.Source, "Topics")
'cn.Close()
'dsTopics.WriteXmlSchema
("gsPath.dstopicsname.xsl")
' On Error GoTo Error1
' Dim sConn As String
' Dim TopicRS As Recordset
' 'sConn = ConnString
= "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source= " &
App.Path & "\hasbarasample.mdb;"
' AddTopic = False
' TopicRS = New Recordset
' TopicRS.Open("Topics", gsConnString,
adOpenDynamic, adLockOptimistic)
' TopicRS.AddNew()
' TopicRS("ParentID") =
gForm.txtParentID.Text
' TopicRS("Title") =
gForm.txtTopicTitle.Text
' TopicRS("Text") = gForm.txtTopicText.Text
' TopicRS("Issuer") = GetItem
(gForm.cboTopicIssuer)
' TopicRS("Length") = Len
(gForm.txtTopicText.Text)
' TopicRS("PointOfView") = GetItem
(gForm.cboPOV)
' TopicRS("PermissionID") = 6
' TopicRS("Publisher") = GetItem
(gForm.cboPublication)
' TopicRS.Update()
' TopicRS.MoveLast()
' gForm.txtID.Text = CStr(TopicRS.Fields
(0))
' AddTopic = True
' TopicRS.Close()
' TopicRS = Nothing
' Exit Function
'Error1:
' Select Case Err.Number
' Case -2147217887, 379
' 'MsgBox CStr(TopicRS.Fields(0))
' Exit Function
' Case Else
' Exit Function
' End Select
End Function
End Class
comboboxes, filling a textbox, a doing a couple other
things. It worked fine, everytime. All the code of this
project is at the end of this post.
Then I tried to take it a step further. That step was to
check all the comboboxes, a couple text boxes to make
sure they had proper contents and selections. Then I
would add a new row to a different table in the database
by using the values of the comboboxes, textboxes and
datetimepicker.value. After I put in that code,
something strange happened. The connection in the
subroutines that filled the comboboxes stopped working.
I'd get the following error message.
An unhandled exception of
type 'System.Data.OleDb.OleDbException' occurred in
system.data.dll
Additional information: No error information available:
DB_SEC_E_AUTH_FAILED(0x80040E4D).
The first thing I tried was commenting out the
clsDChor.NewTopic()
statement in the Private Sub btnSaveTabGeneral_Click
I didn't expect that to work, and it didn't. So I
uncommented it.
The second thing was to place a messagebox statement in
the subfillbox in clsdatachor.vb, to see if the first
attempt to fill a combobox caused the exception, or
whether it was a particular combobox caused it.
The first combobox was named and then the
An unhandled exception of
type 'System.Data.OleDb.OleDbException' occurred in
system.data.dll
Additional information: No error information available:
DB_SEC_E_AUTH_FAILED(0x80040E4D).
exception occured, so no particular combobox was the
culprit. I deleted the msgbox.
The next thing was to comment out the function newtopic
and addtopic in clsdatachor, since filling the list boxes
worked fine before I put these in. Of course I again
commented out the call to the addtopic method.
Nope, didn't work. I left them commented out for the
moment.
Next I created a listbox, put in the statement to fill
it, and called that in form_load.
Didn't work. Deleted the listbox and statement calling it.
Next I tried filling a combobox with a function instead
of a sub. I knew this was grasping at straws, but it
only took a minute or so. Here is the function in
DataChor:
Friend Function AFillBox(ByRef lst As ComboBox, ByVal
strSQL As String, ByVal tbl As String) As Boolean
Dim cn As New OleDbConnection(gstrConn)
cn.Open()
Dim cmd As New OleDbCommand(strSQL, cn)
Dim da As OleDbDataAdapter = New OleDbDataAdapter
da.SelectCommand = cmd
' Fill the DataSet
Dim ds As DataSet = New DataSet
da.Fill(ds, tbl)
Dim tbl1 As DataTable = ds.Tables(0)
Dim row As DataRow = tbl1.Rows(0)
' Bind the DataSet to the DataList
lst.ValueMember = ds.Tables(tbl).Columns
(0).ColumnName
lst.DisplayMember = ds.Tables(tbl).Columns
(1).ColumnName
lst.DataSource = ds.Tables(tbl)
cn.Close()
End Function
As expected, this failed with the same error
message. I deleted the function and the statement
calling it.
The only other thing I added before the comboboxes were
filled was the code behind the save button in the form.
So I commented out the content of the event procedure.
Nope, same error message. Can anybody tell me why cn.open
() failed?
As stated above, the entire code follows.
thanks,
dennist
Imports System.io
Imports System.Data
Imports System.Data.OleDb
Public Class frmTopicFromStart
Inherits System.Windows.Forms.Form
Private mbSaveTabGeneral As Boolean = False
Private mbSaveTabAuthors As Boolean = False
Private mbSaveTabKeywords As Boolean = False
Private mbSaveTabConcepts As Boolean = False
Property SaveTabConcepts() As Boolean
Get
Return mbSaveTabConcepts
End Get
Set(ByVal Value As Boolean)
mbSaveTabConcepts = Value
End Set
End Property
Property SaveTabKeywords() As Boolean
Get
Return mbSaveTabKeywords
End Get
Set(ByVal Value As Boolean)
mbSaveTabKeywords = Value
End Set
End Property
Property SaveTabGeneral() As Boolean
Get
Return mbSaveTabGeneral
End Get
Set(ByVal Value As Boolean)
mbSaveTabGeneral = Value
End Set
End Property
Property SaveTabAuthors() As Boolean
Get
Return mbSaveTabAuthors
End Get
Set(ByVal Value As Boolean)
mbSaveTabAuthors = Value
End Set
End Property
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form
Designer.
InitializeComponent()
'Add any initialization after the
InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component
list.
Protected Overloads Overrides Sub Dispose(ByVal
disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the
Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents TabControl1 As
System.Windows.Forms.TabControl
Friend WithEvents TabPage1 As
System.Windows.Forms.TabPage
Friend WithEvents btnSaveTabGeneral As
System.Windows.Forms.Button
Friend WithEvents txtID As
System.Windows.Forms.TextBox
Friend WithEvents lblID As System.Windows.Forms.Label
Friend WithEvents lblParentID As
System.Windows.Forms.Label
Friend WithEvents txtParentID As
System.Windows.Forms.TextBox
Friend WithEvents lblTopicTitle As
System.Windows.Forms.Label
Friend WithEvents txtTopicTitle As
System.Windows.Forms.TextBox
Friend WithEvents btnOpenFile As
System.Windows.Forms.Button
Friend WithEvents btnDateTransfer As
System.Windows.Forms.Button
Friend WithEvents btnTopicTitle As
System.Windows.Forms.Button
Friend WithEvents lbltxtTextGeneral As
System.Windows.Forms.Label
Friend WithEvents txtTextGeneral As
System.Windows.Forms.TextBox
Friend WithEvents dtp1 As
System.Windows.Forms.DateTimePicker
Friend WithEvents lblDate As
System.Windows.Forms.Label
Friend WithEvents lblDateTypes As
System.Windows.Forms.Label
Friend WithEvents cboDateType As
System.Windows.Forms.ComboBox
Friend WithEvents lblPOV As System.Windows.Forms.Label
Friend WithEvents cboPOV As
System.Windows.Forms.ComboBox
Friend WithEvents lblPermission As
System.Windows.Forms.Label
Friend WithEvents lblPublications As
System.Windows.Forms.Label
Friend WithEvents lblTopicIssuer As
System.Windows.Forms.Label
Friend WithEvents cboPublications As
System.Windows.Forms.ComboBox
Friend WithEvents txtPermission As
System.Windows.Forms.TextBox
Friend WithEvents cboTopicIssuers As
System.Windows.Forms.ComboBox
Friend WithEvents TabPage2 As
System.Windows.Forms.TabPage
Friend WithEvents txtTextAuthors As
System.Windows.Forms.TextBox
Friend WithEvents lblTopicText As
System.Windows.Forms.Label
Friend WithEvents btnSaveTabAuthors As
System.Windows.Forms.Button
Friend WithEvents lblAuthors As
System.Windows.Forms.Label
Friend WithEvents lstAuthors As
System.Windows.Forms.ListBox
Friend WithEvents TabPage3 As
System.Windows.Forms.TabPage
Friend WithEvents ListBox1 As
System.Windows.Forms.ListBox
Friend WithEvents btnQuit As
System.Windows.Forms.Button
Friend WithEvents OFD1 As
System.Windows.Forms.OpenFileDialog
<System.Diagnostics.DebuggerStepThrough()> Private
Sub InitializeComponent()
Me.TabControl1 = New
System.Windows.Forms.TabControl
Me.TabPage1 = New System.Windows.Forms.TabPage
Me.btnSaveTabGeneral = New
System.Windows.Forms.Button
Me.txtID = New System.Windows.Forms.TextBox
Me.lblID = New System.Windows.Forms.Label
Me.lblParentID = New System.Windows.Forms.Label
Me.txtParentID = New System.Windows.Forms.TextBox
Me.lblTopicTitle = New System.Windows.Forms.Label
Me.txtTopicTitle = New
System.Windows.Forms.TextBox
Me.btnOpenFile = New System.Windows.Forms.Button
Me.btnDateTransfer = New
System.Windows.Forms.Button
Me.btnTopicTitle = New System.Windows.Forms.Button
Me.lbltxtTextGeneral = New
System.Windows.Forms.Label
Me.txtTextGeneral = New
System.Windows.Forms.TextBox
Me.dtp1 = New System.Windows.Forms.DateTimePicker
Me.lblDate = New System.Windows.Forms.Label
Me.lblDateTypes = New System.Windows.Forms.Label
Me.cboDateType = New System.Windows.Forms.ComboBox
Me.lblPOV = New System.Windows.Forms.Label
Me.cboPOV = New System.Windows.Forms.ComboBox
Me.lblPermission = New System.Windows.Forms.Label
Me.lblPublications = New
System.Windows.Forms.Label
Me.lblTopicIssuer = New System.Windows.Forms.Label
Me.cboPublications = New
System.Windows.Forms.ComboBox
Me.txtPermission = New
System.Windows.Forms.TextBox
Me.cboTopicIssuers = New
System.Windows.Forms.ComboBox
Me.TabPage2 = New System.Windows.Forms.TabPage
Me.txtTextAuthors = New
System.Windows.Forms.TextBox
Me.lblTopicText = New System.Windows.Forms.Label
Me.btnSaveTabAuthors = New
System.Windows.Forms.Button
Me.lblAuthors = New System.Windows.Forms.Label
Me.lstAuthors = New System.Windows.Forms.ListBox
Me.TabPage3 = New System.Windows.Forms.TabPage
Me.ListBox1 = New System.Windows.Forms.ListBox
Me.btnQuit = New System.Windows.Forms.Button
Me.OFD1 = New System.Windows.Forms.OpenFileDialog
Me.TabControl1.SuspendLayout()
Me.TabPage1.SuspendLayout()
Me.TabPage2.SuspendLayout()
Me.TabPage3.SuspendLayout()
Me.SuspendLayout()
'
'TabControl1
'
Me.TabControl1.Controls.Add(Me.TabPage1)
Me.TabControl1.Controls.Add(Me.TabPage2)
Me.TabControl1.Controls.Add(Me.TabPage3)
Me.TabControl1.Location = New System.Drawing.Point
(24, 32)
Me.TabControl1.Name = "TabControl1"
Me.TabControl1.SelectedIndex = 0
Me.TabControl1.Size = New System.Drawing.Size
(696, 432)
Me.TabControl1.TabIndex = 2
'
'TabPage1
'
Me.TabPage1.Controls.Add(Me.btnSaveTabGeneral)
Me.TabPage1.Controls.Add(Me.txtID)
Me.TabPage1.Controls.Add(Me.lblID)
Me.TabPage1.Controls.Add(Me.lblParentID)
Me.TabPage1.Controls.Add(Me.txtParentID)
Me.TabPage1.Controls.Add(Me.lblTopicTitle)
Me.TabPage1.Controls.Add(Me.txtTopicTitle)
Me.TabPage1.Controls.Add(Me.btnOpenFile)
Me.TabPage1.Controls.Add(Me.btnDateTransfer)
Me.TabPage1.Controls.Add(Me.btnTopicTitle)
Me.TabPage1.Controls.Add(Me.lbltxtTextGeneral)
Me.TabPage1.Controls.Add(Me.txtTextGeneral)
Me.TabPage1.Controls.Add(Me.dtp1)
Me.TabPage1.Controls.Add(Me.lblDate)
Me.TabPage1.Controls.Add(Me.lblDateTypes)
Me.TabPage1.Controls.Add(Me.cboDateType)
Me.TabPage1.Controls.Add(Me.lblPOV)
Me.TabPage1.Controls.Add(Me.cboPOV)
Me.TabPage1.Controls.Add(Me.lblPermission)
Me.TabPage1.Controls.Add(Me.lblPublications)
Me.TabPage1.Controls.Add(Me.lblTopicIssuer)
Me.TabPage1.Controls.Add(Me.cboPublications)
Me.TabPage1.Controls.Add(Me.txtPermission)
Me.TabPage1.Controls.Add(Me.cboTopicIssuers)
Me.TabPage1.Location = New System.Drawing.Point
(4, 22)
Me.TabPage1.Name = "TabPage1"
Me.TabPage1.Size = New System.Drawing.Size(688,
406)
Me.TabPage1.TabIndex = 0
Me.TabPage1.Text = "General"
'
'btnSaveTabGeneral
'
Me.btnSaveTabGeneral.Location = New
System.Drawing.Point(576, 320)
Me.btnSaveTabGeneral.Name = "btnSaveTabGeneral"
Me.btnSaveTabGeneral.Size = New
System.Drawing.Size(88, 56)
Me.btnSaveTabGeneral.TabIndex = 24
Me.btnSaveTabGeneral.Text = "Save"
'
'txtID
'
Me.txtID.Location = New System.Drawing.Point(536,
264)
Me.txtID.Name = "txtID"
Me.txtID.ReadOnly = True
Me.txtID.Size = New System.Drawing.Size(128, 20)
Me.txtID.TabIndex = 23
Me.txtID.Text = ""
'
'lblID
'
Me.lblID.Location = New System.Drawing.Point(536,
248)
Me.lblID.Name = "lblID"
Me.lblID.Size = New System.Drawing.Size(104, 16)
Me.lblID.TabIndex = 22
Me.lblID.Text = "ID"
'
'lblParentID
'
Me.lblParentID.Location = New System.Drawing.Point
(536, 184)
Me.lblParentID.Name = "lblParentID"
Me.lblParentID.Size = New System.Drawing.Size
(112, 16)
Me.lblParentID.TabIndex = 21
Me.lblParentID.Text = "ParentID"
'
'txtParentID
'
Me.txtParentID.Location = New System.Drawing.Point
(536, 200)
Me.txtParentID.Name = "txtParentID"
Me.txtParentID.ReadOnly = True
Me.txtParentID.Size = New System.Drawing.Size
(128, 20)
Me.txtParentID.TabIndex = 20
Me.txtParentID.Text = "0"
'
'lblTopicTitle
'
Me.lblTopicTitle.Location = New
System.Drawing.Point(536, 64)
Me.lblTopicTitle.Name = "lblTopicTitle"
Me.lblTopicTitle.Size = New System.Drawing.Size
(80, 16)
Me.lblTopicTitle.TabIndex = 19
Me.lblTopicTitle.Text = "Topic Title"
'
'txtTopicTitle
'
Me.txtTopicTitle.Location = New
System.Drawing.Point(536, 80)
Me.txtTopicTitle.Multiline = True
Me.txtTopicTitle.Name = "txtTopicTitle"
Me.txtTopicTitle.ScrollBars =
System.Windows.Forms.ScrollBars.Vertical
Me.txtTopicTitle.Size = New System.Drawing.Size
(128, 80)
Me.txtTopicTitle.TabIndex = 18
Me.txtTopicTitle.Text = ""
'
'btnOpenFile
'
Me.btnOpenFile.Location = New System.Drawing.Point
(424, 48)
Me.btnOpenFile.Name = "btnOpenFile"
Me.btnOpenFile.Size = New System.Drawing.Size(72,
32)
Me.btnOpenFile.TabIndex = 17
Me.btnOpenFile.Text = "Open File"
'
'btnDateTransfer
'
Me.btnDateTransfer.Location = New
System.Drawing.Point(328, 48)
Me.btnDateTransfer.Name = "btnDateTransfer"
Me.btnDateTransfer.Size = New System.Drawing.Size
(88, 32)
Me.btnDateTransfer.TabIndex = 16
Me.btnDateTransfer.Text = "Date Transfer"
'
'btnTopicTitle
'
Me.btnTopicTitle.Location = New
System.Drawing.Point(256, 48)
Me.btnTopicTitle.Name = "btnTopicTitle"
Me.btnTopicTitle.Size = New System.Drawing.Size
(64, 32)
Me.btnTopicTitle.TabIndex = 15
Me.btnTopicTitle.Text = "Topic Title"
'
'lbltxtTextGeneral
'
Me.lbltxtTextGeneral.Location = New
System.Drawing.Point(192, 64)
Me.lbltxtTextGeneral.Name = "lbltxtTextGeneral"
Me.lbltxtTextGeneral.Size = New
System.Drawing.Size(64, 16)
Me.lbltxtTextGeneral.TabIndex = 14
Me.lbltxtTextGeneral.Text = "Topic Text"
'
'txtTextGeneral
'
Me.txtTextGeneral.Location = New
System.Drawing.Point(192, 80)
Me.txtTextGeneral.Multiline = True
Me.txtTextGeneral.Name = "txtTextGeneral"
Me.txtTextGeneral.ScrollBars =
System.Windows.Forms.ScrollBars.Vertical
Me.txtTextGeneral.Size = New System.Drawing.Size
(304, 296)
Me.txtTextGeneral.TabIndex = 13
Me.txtTextGeneral.Text = ""
'
'dtp1
'
Me.dtp1.Format =
System.Windows.Forms.DateTimePickerFormat.Short
Me.dtp1.Location = New System.Drawing.Point(24,
360)
Me.dtp1.Name = "dtp1"
Me.dtp1.Size = New System.Drawing.Size(128, 20)
Me.dtp1.TabIndex = 12
'
'lblDate
'
Me.lblDate.Location = New System.Drawing.Point
(24, 344)
Me.lblDate.Name = "lblDate"
Me.lblDate.Size = New System.Drawing.Size(80, 16)
Me.lblDate.TabIndex = 11
Me.lblDate.Text = "Date"
'
'lblDateTypes
'
Me.lblDateTypes.Location = New
System.Drawing.Point(24, 288)
Me.lblDateTypes.Name = "lblDateTypes"
Me.lblDateTypes.Size = New System.Drawing.Size
(64, 16)
Me.lblDateTypes.TabIndex = 9
Me.lblDateTypes.Text = "DateTypes"
'
'cboDateType
'
Me.cboDateType.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList
Me.cboDateType.DropDownWidth = 192
Me.cboDateType.Location = New System.Drawing.Point
(24, 304)
Me.cboDateType.Name = "cboDateType"
Me.cboDateType.Size = New System.Drawing.Size
(128, 21)
Me.cboDateType.TabIndex = 8
'
'lblPOV
'
Me.lblPOV.Location = New System.Drawing.Point(24,
176)
Me.lblPOV.Name = "lblPOV"
Me.lblPOV.Size = New System.Drawing.Size(88, 16)
Me.lblPOV.TabIndex = 7
Me.lblPOV.Text = "Points of View"
'
'cboPOV
'
Me.cboPOV.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList
Me.cboPOV.DropDownWidth = 192
Me.cboPOV.Location = New System.Drawing.Point(24,
192)
Me.cboPOV.Name = "cboPOV"
Me.cboPOV.Size = New System.Drawing.Size(128, 21)
Me.cboPOV.TabIndex = 6
'
'lblPermission
'
Me.lblPermission.Location = New
System.Drawing.Point(24, 232)
Me.lblPermission.Name = "lblPermission"
Me.lblPermission.Size = New System.Drawing.Size
(80, 16)
Me.lblPermission.TabIndex = 5
Me.lblPermission.Text = "Permission"
'
'lblPublications
'
Me.lblPublications.Location = New
System.Drawing.Point(24, 120)
Me.lblPublications.Name = "lblPublications"
Me.lblPublications.Size = New System.Drawing.Size
(100, 16)
Me.lblPublications.TabIndex = 4
Me.lblPublications.Text = "Publications"
'
'lblTopicIssuer
'
Me.lblTopicIssuer.Location = New
System.Drawing.Point(24, 64)
Me.lblTopicIssuer.Name = "lblTopicIssuer"
Me.lblTopicIssuer.Size = New System.Drawing.Size
(100, 16)
Me.lblTopicIssuer.TabIndex = 3
Me.lblTopicIssuer.Text = "TopicIssuers"
'
'cboPublications
'
Me.cboPublications.DropDownWidth = 192
Me.cboPublications.Location = New
System.Drawing.Point(24, 136)
Me.cboPublications.Name = "cboPublications"
Me.cboPublications.Size = New System.Drawing.Size
(128, 21)
Me.cboPublications.TabIndex = 2
'
'txtPermission
'
Me.txtPermission.BackColor =
System.Drawing.SystemColors.Control
Me.txtPermission.Location = New
System.Drawing.Point(24, 248)
Me.txtPermission.Name = "txtPermission"
Me.txtPermission.ReadOnly = True
Me.txtPermission.Size = New System.Drawing.Size
(128, 20)
Me.txtPermission.TabIndex = 1
Me.txtPermission.Text = "6"
'
'cboTopicIssuers
'
Me.cboTopicIssuers.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList
Me.cboTopicIssuers.DropDownWidth = 192
Me.cboTopicIssuers.Location = New
System.Drawing.Point(24, 80)
Me.cboTopicIssuers.Name = "cboTopicIssuers"
Me.cboTopicIssuers.Size = New System.Drawing.Size
(128, 21)
Me.cboTopicIssuers.TabIndex = 0
'
'TabPage2
'
Me.TabPage2.Controls.Add(Me.txtTextAuthors)
Me.TabPage2.Controls.Add(Me.lblTopicText)
Me.TabPage2.Controls.Add(Me.btnSaveTabAuthors)
Me.TabPage2.Controls.Add(Me.lblAuthors)
Me.TabPage2.Controls.Add(Me.lstAuthors)
Me.TabPage2.Location = New System.Drawing.Point
(4, 22)
Me.TabPage2.Name = "TabPage2"
Me.TabPage2.Size = New System.Drawing.Size(688,
406)
Me.TabPage2.TabIndex = 1
Me.TabPage2.Text = "Authors"
Me.TabPage2.Visible = False
'
'txtTextAuthors
'
Me.txtTextAuthors.Location = New
System.Drawing.Point(280, 64)
Me.txtTextAuthors.Multiline = True
Me.txtTextAuthors.Name = "txtTextAuthors"
Me.txtTextAuthors.ReadOnly = True
Me.txtTextAuthors.Size = New System.Drawing.Size
(364, 296)
Me.txtTextAuthors.TabIndex = 4
Me.txtTextAuthors.Text = "TextBox1"
'
'lblTopicText
'
Me.lblTopicText.Location = New
System.Drawing.Point(280, 48)
Me.lblTopicText.Name = "lblTopicText"
Me.lblTopicText.Size = New System.Drawing.Size
(112, 16)
Me.lblTopicText.TabIndex = 3
Me.lblTopicText.Text = "Topic Text"
'
'btnSaveTabAuthors
'
Me.btnSaveTabAuthors.Location = New
System.Drawing.Point(176, 320)
Me.btnSaveTabAuthors.Name = "btnSaveTabAuthors"
Me.btnSaveTabAuthors.Size = New
System.Drawing.Size(64, 40)
Me.btnSaveTabAuthors.TabIndex = 2
Me.btnSaveTabAuthors.Text = "Save"
'
'lblAuthors
'
Me.lblAuthors.Location = New System.Drawing.Point
(40, 48)
Me.lblAuthors.Name = "lblAuthors"
Me.lblAuthors.Size = New System.Drawing.Size(112,
16)
Me.lblAuthors.TabIndex = 1
Me.lblAuthors.Text = "Authors"
'
'lstAuthors
'
Me.lstAuthors.Location = New System.Drawing.Point
(40, 64)
Me.lstAuthors.Name = "lstAuthors"
Me.lstAuthors.Size = New System.Drawing.Size(200,
212)
Me.lstAuthors.TabIndex = 0
'
'TabPage3
'
Me.TabPage3.Controls.Add(Me.ListBox1)
Me.TabPage3.Location = New System.Drawing.Point
(4, 22)
Me.TabPage3.Name = "TabPage3"
Me.TabPage3.Size = New System.Drawing.Size(688,
406)
Me.TabPage3.TabIndex = 2
Me.TabPage3.Text = "Keywords"
Me.TabPage3.Visible = False
'
'ListBox1
'
Me.ListBox1.Location = New System.Drawing.Point
(208, 56)
Me.ListBox1.Name = "ListBox1"
Me.ListBox1.Size = New System.Drawing.Size(280,
251)
Me.ListBox1.TabIndex = 0
'
'btnQuit
'
Me.btnQuit.Location = New System.Drawing.Point
(632, 496)
Me.btnQuit.Name = "btnQuit"
Me.btnQuit.Size = New System.Drawing.Size(88, 32)
Me.btnQuit.TabIndex = 3
Me.btnQuit.Text = "Quit"
'
'frmTopicFromStart
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5,
13)
Me.ClientSize = New System.Drawing.Size(744, 550)
Me.Controls.Add(Me.btnQuit)
Me.Controls.Add(Me.TabControl1)
Me.Name = "frmTopicFromStart"
Me.Text = "Form1"
Me.TabControl1.ResumeLayout(False)
Me.TabPage1.ResumeLayout(False)
Me.TabPage2.ResumeLayout(False)
Me.TabPage3.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub togethelp()
Dim str1 As String
'str1.
'IsDate()
End Sub
Private Sub btnQuit_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnQuit.Click
End
End Sub
Private Sub frmtopicfromstart_Load(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
Dim clsDChor As New clsDataChor
txtTextGeneral.Text = ""
clsDChor.FillBox(cboTopicIssuers, "SELECT
TopicIssuers.ID, TopicIssuers.Issuer FROM TopicIssuers
ORDER BY TopicIssuers.Issuer;", "TopicIssuers")
clsDChor.FillBox(cboPublications, "SELECT
Publications.ID, Publications.Publication FROM
Publications ORDER BY
Publications.Publication;", "Publications")
clsDChor.FillBox(cboPOV, "SELECT PointsOfView.ID,
PointsOfView.PointOfView FROM PointsOfView ORDER BY
PointsOfView.PointOfView;", "PointsOfView")
clsDChor.FillBox(cboDateType, "SELECT
DateType.ID, DateType.DateType FROM DateType ORDER BY
DateType.DateType;", "DateType")
'Dim strDate As String = "05/22/2003"
'If IsDate(strDate) Then
' dtp1.Value = strDate
'End If
End Sub
Private Sub TabControl1_SelectedIndexChanged(ByVal
sender As Object, ByVal e As System.EventArgs) Handles
TabControl1.SelectedIndexChanged
'MsgBox(cboCustomers.SelectedIndex.ToString)
If cboTopicIssuers.SelectedIndex >= 0 Then
If txtTopicTitle.Text = "" Then
TabControl1.SelectedTab = TabPage1
End If
End If
End Sub
Private Sub TabPage1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
TabPage1.Click
End Sub
Private Sub cboTopicIssuers_SelectedIndexChanged
(ByVal sender As Object, ByVal e As System.EventArgs)
Handles cboTopicIssuers.SelectedIndexChanged
'MsgBox(cboTopicIssuers.SelectedIndex)
End Sub
Private Sub btnTopicTitle_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnTopicTitle.Click
' Declares an IDataObject to hold the data
returned from the clipboard.
' Retrieves the data from the clipboard.
Clipboard.SetDataObject
(txtTextGeneral.SelectedText, True)
'MsgBox("btntopictitle " &
txtTextGeneral.SelectedText)
Dim iData As IDataObject = Clipboard.GetDataObject
()
Dim str1 As String
' Determines whether the data is in a format you
can use.
If txtTextGeneral.SelectedText = "" Then
MsgBox("No text is selected.")
Exit Sub
End If
If iData.GetDataPresent(DataFormats.Text) Then
str1 = CType(iData.GetData(DataFormats.Text),
String)
'MsgBox(str1)
'If str1.Length = 0 Then
' MsgBox("There is no text in the
clipboard.")
' Exit Sub
'End If
' Yes it is, so display it in a text box.
txtTopicTitle.Text = CType(iData.GetData
(DataFormats.Text), String)
Else
' No it is not.
MsgBox("The clipboard contained something
other than text")
Exit Sub
End If
End Sub
Private Sub txtTextGeneral_TextChanged(ByVal sender
As System.Object, ByVal e As System.EventArgs) Handles
txtTextGeneral.TextChanged
End Sub
Private Sub txtTextGeneral_LostFocus(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
txtTextGeneral.LostFocus
'' Takes the selected text from a text box and
puts it on the clipboard.
'txtTopicTitle.Text = "Leave" 'see leave
'MsgBox("Leave")
'If txtTextGeneral.SelectedText <> "" Then
' Clipboard.SetDataObject
(txtTextGeneral.SelectedText, True)
'Else
' MsgBox("No text selected", , "Warning")
' txtTitle.Text = ""
'End If
End Sub
Private Sub btnOpenFile_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnOpenFile.Click
Dim StreamR1 As System.IO.StreamReader
OFD1.Filter = ("text files(*.txt)|*.txt|(Word
files(*.doc)|*.doc")
OFD1.ShowDialog()
If OFD1.FileName <> "" Then
Try 'open file and trap any erros using
handler
StreamR1 = New StreamReader(OFD1.FileName)
txtTextGeneral.Text = StreamR1.ReadToEnd
StreamR1.Close()
txtTextGeneral.Select(0, 0)
Catch
MsgBox("Error opening file." & vbCr
& "Perhaps bad file name", , "Error!")
Finally
txtTextGeneral.Focus()
'MsgBox(txtTextGeneral.SelectedText)
End Try
End If
End Sub
Private Sub btnDateTransfer_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnDateTransfer.Click
' Declares an IDataObject to hold the data
returned from the clipboard.
' Retrieves the data from the clipboard.
Clipboard.SetDataObject
(txtTextGeneral.SelectedText, True)
Dim iData As IDataObject = Clipboard.GetDataObject
()
Dim str1 As String
' Determines whether the data is in a format you
can use.
If txtTextGeneral.SelectedText = "" Then
MsgBox("No text is selected.")
Exit Sub
End If
If iData.GetDataPresent(DataFormats.Text) Then
str1 = CType(iData.GetData(DataFormats.Text),
String)
' Yes it is, so display it in a text box.
If IsDate(str1) Then
dtp1.Value = str1
Else
MsgBox("Selected text was not a date.")
End If
'txtTopicTitle.Text = CType(iData.GetData
(DataFormats.Text), String)
Else
' No it is not.
MsgBox("The clipboard contained something
other than text")
Exit Sub
End If
End Sub
Private Sub txtTextGeneral_Leave(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
txtTextGeneral.Leave
' Takes the selected text from a text box and
puts it on the clipboard.
'txtTopicTitle.Text = "leave" 'only true if hit
control that can accept text
'MsgBox("Leave")
'If txtTextGeneral.SelectedText <> "" Then
' Clipboard.SetDataObject
(txtTextGeneral.SelectedText, True)
'Else
' MsgBox("No text selected", , "Warning")
' txtTitle.Text = ""
'End If
End Sub
Private Sub TabPage2_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
TabPage2.Click
End Sub
Private Sub btnSaveTabGeneral_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnSaveTabGeneral.Click
Dim clsDChor As New clsDataChor
If cboTopicIssuers.SelectedIndex = -1 Then
MsgBox("No Topic Issuer selected.")
cboTopicIssuers.Focus()
Exit Sub
ElseIf cboPublications.SelectedIndex = -1 Then
MsgBox("No Publication selected.")
cboPublications.Focus()
Exit Sub
ElseIf cboPOV.SelectedIndex = -1 Then
MsgBox("No Point of View selected.")
cboPOV.Focus()
Exit Sub
ElseIf txtPermission.Text <> "6" Then
txtPermission.Text = "6"
' Exit Sub
ElseIf cboDateType.SelectedIndex = -1 Then
MsgBox("No Date Type is selected.")
cboDateType.Focus()
Exit Sub
ElseIf Not IsDate(dtp1.Value) Then
MsgBox("The date box does not contain a
date.")
dtp1.Focus()
Exit Sub
ElseIf txtTextGeneral.Text = "" Then
MsgBox("There is no topic text.")
btnOpenFile.Focus()
Exit Sub
ElseIf txtTopicTitle.Text = "" Then
MsgBox("There is no topic title.")
txtTopicTitle.Focus()
Exit Sub
End If
gForm = Me
''
gsTopicText = txtTextGeneral.Text
txtTextGeneral.ReadOnly = True
'txtTopicText.BackColor = &HE0E0E0
txtTextAuthors.Text = gsTopicText
txtTextAuthors.ReadOnly = True
'txtTopicText2.Text = gsTopicText
'txtTopicText2.Locked = True
clsDChor.NewTopic()
'cmdSaveLOG.Enabled = False
'gID = CLng(txtID.Text)
End Sub
End Class
Imports System.Data
Imports System.io
Module modPrimary
Friend gstrConn As String
= "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" 'H:\HasbaraNET\ado.net
tests\adonetTest\HasbaraSample.mdb;"
Public s As String
Public gSelectedFile As String
Public gForm As Form
Public gsTopicText As String
Public gID As Integer
Public gsPath As String
Public Sub Main()
Dim strPath As String
Dim strSubstring As String
Dim intIndexof As Integer
Dim cls1 As New Class1
strPath =
System.Reflection.Assembly.GetExecutingAssembly.Location
intIndexof = strPath.IndexOf("bin")
strSubstring = strPath.Substring(0, intIndexof)
gsPath = strSubstring
ChDir(strSubstring)
gstrConn = gstrConn & "HasbaraSample.mdb;"
SetGlobals()
Application.Run(New frmTopicFromStart)
End Sub
Public Sub SetGlobals()
gSelectedFile = ""
End Sub
End Module
Public Class Class1
Public Shared Function GetFileNameWithoutExtension( _
ByVal path As String _
) As String
End Function
Public Shared Function GetDirectoryName( _
ByVal path As String _
) As String
End Function
End Class
Imports System.Data.oledb
Public Class clsDataChor
Overloads Sub FillBox(ByRef lst As ListBox, ByVal
strSQL As String, ByVal tbl As String)
Dim cn As New OleDbConnection(gstrConn)
cn.Open()
Dim cmd As New OleDbCommand(strSQL, cn)
Dim da As OleDbDataAdapter = New OleDbDataAdapter
da.SelectCommand = cmd
' Fill the DataSet
Dim ds As DataSet = New DataSet
da.Fill(ds, tbl)
Dim tbl1 As DataTable = ds.Tables(0)
Dim row As DataRow = tbl1.Rows(0)
' Bind the DataSet to the DataList
lst.ValueMember = ds.Tables(tbl).Columns
(0).ColumnName
lst.DisplayMember = ds.Tables(tbl).Columns
(1).ColumnName
lst.DataSource = ds.Tables(tbl)
cn.Close()
End Sub
Overloads Sub FillBox(ByRef lst As ComboBox, ByVal
strSQL As String, ByVal tbl As String)
Dim cn As New OleDbConnection(gstrConn)
cn.Open()
Dim cmd As New OleDbCommand(strSQL, cn)
Dim da As OleDbDataAdapter = New OleDbDataAdapter
da.SelectCommand = cmd
' Fill the DataSet
Dim ds As DataSet = New DataSet
da.Fill(ds, tbl)
' Bind the DataSet to the DataList
lst.ValueMember = ds.Tables(tbl).Columns
(0).ColumnName
lst.DisplayMember = ds.Tables(tbl).Columns
(1).ColumnName
lst.DataSource = ds.Tables(tbl)
cn.Close()
End Sub
Friend Function NewTopic() As Boolean
NewTopic = False
Dim cn As New OleDbConnection(gstrConn)
'cn.Open()
MsgBox("after dim cn")
Dim cmd As New OleDbCommand("SELECT * FROM
Topics", cn)
Dim da As OleDbDataAdapter = New OleDbDataAdapter
da.SelectCommand = cmd
MsgBox("before dataset")
' Fill the DataSet
Dim ds As DataSet = New DataSet
ds.DataSetName = "ds1"
'dim tblTopics as ds
da.Fill(ds, "Topics")
cn.Open()
da.FillSchema(ds, SchemaType.Source, "Topics")
ds.WriteXmlSchema("H:\Program Files\Microsoft
Visual Studio .NET 2003\Common7
\IDE\WorkingDirectory.ds.xsl")
MsgBox(ds.Tables.Item(0))
'da..Tables.
'Dim dsTopics As New dsname
'dim tblTopics as ds.
'Dim tblCustomers As Chapter9.CustomersDataTable
= ds.Customers
'Dim rowCustomer As Chapter9.CustomersRow
'rowCustomer = tblCustomers.NewCustomersRow()
'rowCustomer.CustomerID = "ABCDE"
'rowCustomer.CompanyName = "New Company"
'rowCustomer.ContactName = "New Contact"
'rowCustomer.Phone = "(800) 555-1212"
'tblCustomers.AddCustomersRow(rowCustomer)
''Instead of
'Dim rowCustomer As DataRow = tblCustomers.NewRow
()
'rowCustomer("CustomerID") = "ABCDE"
'rowCustomer("CompanyName") = "New Company"
'rowCustomer("ContactName") = "New Contact"
'rowCustomer("Phone") = "(800) 555-1212"
'tblCustomers.Rows.Add(rowCustomer)
Return True
cn.Close()
Dim cn1 As New OleDbConnection(gstrConn)
cn1.Open()
'Dim cmd1 As New OleDbCommand("SELECT * FROM
Topics", cn1)
'Dim da1 As OleDbda1taAda1pter = New
OleDbda1taAda1pter
'da1.SelectCommand = cmd1
'' Fill the da1taSet
'Dim ds1 As da1taSet = New da1taSet
'ds1.da1taSetName = "ds1Name"
''dim tblTopics as ds1
'da1.Fill(ds1, "Topics")
'cn1.Open()
'da1.FillSchema(ds1, SchemaType.Source, "Topics")
'ds1.WriteXmlSchema("gsPath.ds1topics.xsl")
''da1..Tables.
''Dim ds1Topics As New ds1name
''dim tblTopics as ds1.
''Dim tblCustomers As
Chapter9.Customersda1taTable = ds1.Customers
''Dim rowCustomer As Chapter9.CustomersRow
''rowCustomer = tblCustomers.NewCustomersRow()
''rowCustomer.CustomerID = "ABCDE"
''rowCustomer.CompanyName = "New Company"
''rowCustomer.ContactName = "New Contact"
''rowCustomer.Phone = "(800) 555-1212"
''tblCustomers.AddCustomersRow(rowCustomer)
'''Instead of
''Dim rowCustomer As da1taRow =
tblCustomers.NewRow()
''rowCustomer("CustomerID") = "ABCDE"
''rowCustomer("CompanyName") = "New Company"
''rowCustomer("ContactName") = "New Contact"
''rowCustomer("Phone") = "(800) 555-1212"
''tblCustomers.Rows.Add(rowCustomer)
'Return True
'cn1.Close()
End Function
Public Function AddTopic() As Boolean
AddTopic = False
Dim cn As New OleDbConnection(gstrConn)
Try
cn.Open()
Catch e As OleDbException
Dim errorMessages As String
Dim i As Integer
For i = 0 To e.Errors.Count - 1
errorMessages += "Index #" & i.ToString()
& ControlChars.Cr _
& "Message: " & e.Errors
(i).Message & ControlChars.Cr _
& "NativeError: " &
e.Errors(i).NativeError & ControlChars.Cr _
& "Source: " & e.Errors
(i).Source & ControlChars.Cr _
& "SQLState: " & e.Errors
(i).SQLState & ControlChars.Cr
Next i
Dim log As System.Diagnostics.EventLog = New
System.Diagnostics.EventLog
log.Source = "My Application"
log.WriteEntry(errorMessages)
Console.WriteLine("An exception occurred.
Please contact your system administrator.")
End Try
'Dim mySelectQuery As String = "SELECT column1
FROM table1"
'Dim myConnection As New OleDbConnection _
'
("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=")
'Dim myCommand As New OleDbCommand(mySelectQuery,
myConnection)
'Try
' myCommand.Connection.Open()
'Catch e As OleDbException
' Dim errorMessages As String
' Dim i As Integer
' For i = 0 To e.Errors.Count - 1
' errorMessages += "Index #" & i.ToString
() & ControlChars.Cr _
' & "Message: " & e.Errors
(i).Message & ControlChars.Cr _
' & "NativeError: " &
e.Errors(i).NativeError & ControlChars.Cr _
' & "Source: " & e.Errors
(i).Source & ControlChars.Cr _
' & "SQLState: " & e.Errors
(i).SQLState & ControlChars.Cr
' Next i
' Dim log As System.Diagnostics.EventLog = New
System.Diagnostics.EventLog
' log.Source = "My Application"
' log.WriteEntry(errorMessages)
' Console.WriteLine("An exception occurred.
Please contact your system administrator.")
'End Try
'MsgBox(gstrConn)
'Dim strSQL As String = "select * from topics;"
'Dim dsTopics As New DataSet
'dsTopics.DataSetName = "dsTopicsName"
'MsgBox(dsTopics.DataSetName)
''cn.Open()
'Dim daTopics As New OleDbDataAdapter(strSQL, cn)
'daTopics.FillSchema(dsTopics,
SchemaType.Source, "Topics")
'cn.Close()
'dsTopics.WriteXmlSchema
("gsPath.dstopicsname.xsl")
' On Error GoTo Error1
' Dim sConn As String
' Dim TopicRS As Recordset
' 'sConn = ConnString
= "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source= " &
App.Path & "\hasbarasample.mdb;"
' AddTopic = False
' TopicRS = New Recordset
' TopicRS.Open("Topics", gsConnString,
adOpenDynamic, adLockOptimistic)
' TopicRS.AddNew()
' TopicRS("ParentID") =
gForm.txtParentID.Text
' TopicRS("Title") =
gForm.txtTopicTitle.Text
' TopicRS("Text") = gForm.txtTopicText.Text
' TopicRS("Issuer") = GetItem
(gForm.cboTopicIssuer)
' TopicRS("Length") = Len
(gForm.txtTopicText.Text)
' TopicRS("PointOfView") = GetItem
(gForm.cboPOV)
' TopicRS("PermissionID") = 6
' TopicRS("Publisher") = GetItem
(gForm.cboPublication)
' TopicRS.Update()
' TopicRS.MoveLast()
' gForm.txtID.Text = CStr(TopicRS.Fields
(0))
' AddTopic = True
' TopicRS.Close()
' TopicRS = Nothing
' Exit Function
'Error1:
' Select Case Err.Number
' Case -2147217887, 379
' 'MsgBox CStr(TopicRS.Fields(0))
' Exit Function
' Case Else
' Exit Function
' End Select
End Function
End Class