{"id":2327,"date":"2014-12-18T19:58:43","date_gmt":"2014-12-18T19:58:43","guid":{"rendered":"https:\/\/alt2.minisoft.com\/support\/?p=2327"},"modified":"2017-01-29T23:10:02","modified_gmt":"2017-01-29T23:10:02","slug":"vb-net-sample-using-odbc-net-data-provider-and-ado","status":"publish","type":"post","link":"https:\/\/c002.minisoft.com\/support\/vb-net-sample-using-odbc-net-data-provider-and-ado\/","title":{"rendered":"VB.NET Sample Using ODBC .NET Data Provider and ADO"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p>Download the sample: [<a href=\"https:\/\/alt2.minisoft.com\/support\/wp-content\/uploads\/2014\/12\/ADONET.zip\"><span style=\"color: #003399;\"><span style=\"text-decoration: underline;\">HTTP<\/span><\/span><\/a>]<\/p>\n<p>&nbsp;<\/p>\n<p>Imports Microsoft.Data.Odbc<\/p>\n<p>Public Class Form1<br \/>\nInherits System.Windows.Forms.Form<\/p>\n<p>#Region &#8221; Windows Form Designer generated code &#8221;<\/p>\n<p>Public Sub New()<br \/>\nMyBase.New()<\/p>\n<p>&#8216;This call is required by the Windows Form Designer.<br \/>\nInitializeComponent()<\/p>\n<p>&#8216;Add any initialization after the InitializeComponent() call<\/p>\n<p>End Sub<\/p>\n<p>&#8216;Form overrides dispose to clean up the component list.<br \/>\nProtected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)<br \/>\nIf disposing Then<br \/>\nIf Not (components Is Nothing) Then<br \/>\ncomponents.Dispose()<br \/>\nEnd If<br \/>\nEnd If<br \/>\nMyBase.Dispose(disposing)<br \/>\nEnd Sub<\/p>\n<p>&#8216;Required by the Windows Form Designer<br \/>\nPrivate components As System.ComponentModel.IContainer<\/p>\n<p>&#8216;NOTE: The following procedure is required by the Windows Form Designer<br \/>\n&#8216;It can be modified using the Windows Form Designer.<br \/>\n&#8216;Do not modify it using the code editor.<br \/>\nFriend WithEvents Button1 As System.Windows.Forms.Button<br \/>\nFriend WithEvents TextBox1 As System.Windows.Forms.TextBox<br \/>\nFriend WithEvents password As System.Windows.Forms.TextBox<br \/>\nFriend WithEvents hpgroup As System.Windows.Forms.TextBox<br \/>\nFriend WithEvents Button2 As System.Windows.Forms.Button<br \/>\nFriend WithEvents Label1 As System.Windows.Forms.Label<br \/>\nFriend WithEvents Label2 As System.Windows.Forms.Label<br \/>\nFriend WithEvents Label3 As System.Windows.Forms.Label<br \/>\n&lt;system.diagnostics.debuggerstepthrough()&gt;\u00a0Private Sub InitializeComponent()<br \/>\nMe.Button1 = New System.Windows.Forms.Button()<br \/>\nMe.TextBox1 = New System.Windows.Forms.TextBox()<br \/>\nMe.password = New System.Windows.Forms.TextBox()<br \/>\nMe.hpgroup = New System.Windows.Forms.TextBox()<br \/>\nMe.Button2 = New System.Windows.Forms.Button()<br \/>\nMe.Label1 = New System.Windows.Forms.Label()<br \/>\nMe.Label2 = New System.Windows.Forms.Label()<br \/>\nMe.Label3 = New System.Windows.Forms.Label()<br \/>\nMe.SuspendLayout()<br \/>\n&#8216;<br \/>\n&#8216;Button1<br \/>\n&#8216;<br \/>\nMe.Button1.Location = New System.Drawing.Point(136, 24)<br \/>\nMe.Button1.Name = &#8220;Button1&#8221;<br \/>\nMe.Button1.Size = New System.Drawing.Size(112, 30)<br \/>\nMe.Button1.TabIndex = 2<br \/>\nMe.Button1.Text = &#8220;Use ADO&#8221;<br \/>\n&#8216;<br \/>\n&#8216;TextBox1<br \/>\n&#8216;<br \/>\nMe.TextBox1.Location = New System.Drawing.Point(192, 200)<br \/>\nMe.TextBox1.Name = &#8220;TextBox1&#8221;<br \/>\nMe.TextBox1.ReadOnly = True<br \/>\nMe.TextBox1.Size = New System.Drawing.Size(200, 20)<br \/>\nMe.TextBox1.TabIndex = 1<br \/>\nMe.TextBox1.TabStop = False<br \/>\nMe.TextBox1.Text = &#8220;TextBox1&#8221;<br \/>\n&#8216;<br \/>\n&#8216;password<br \/>\n&#8216;<br \/>\nMe.password.Location = New System.Drawing.Point(192, 96)<br \/>\nMe.password.Name = &#8220;password&#8221;<br \/>\nMe.password.PasswordChar = Microsoft.VisualBasic.ChrW(42)<br \/>\nMe.password.Size = New System.Drawing.Size(200, 20)<br \/>\nMe.password.TabIndex = 0<br \/>\nMe.password.Text = &#8220;&#8221;<br \/>\n&#8216;<br \/>\n&#8216;hpgroup<br \/>\n&#8216;<br \/>\nMe.hpgroup.Location = New System.Drawing.Point(192, 136)<br \/>\nMe.hpgroup.Name = &#8220;hpgroup&#8221;<br \/>\nMe.hpgroup.Size = New System.Drawing.Size(200, 20)<br \/>\nMe.hpgroup.TabIndex = 1<br \/>\nMe.hpgroup.Text = &#8220;PUB&#8221;<br \/>\n&#8216;<br \/>\n&#8216;Button2<br \/>\n&#8216;<br \/>\nMe.Button2.Location = New System.Drawing.Point(280, 24)<br \/>\nMe.Button2.Name = &#8220;Button2&#8221;<br \/>\nMe.Button2.Size = New System.Drawing.Size(112, 32)<br \/>\nMe.Button2.TabIndex = 3<br \/>\nMe.Button2.Text = &#8220;Use ODBC .NET&#8221;<br \/>\n&#8216;<br \/>\n&#8216;Label1<br \/>\n&#8216;<br \/>\nMe.Label1.Location = New System.Drawing.Point(88, 96)<br \/>\nMe.Label1.Name = &#8220;Label1&#8221;<br \/>\nMe.Label1.Size = New System.Drawing.Size(88, 24)<br \/>\nMe.Label1.TabIndex = 4<br \/>\nMe.Label1.Text = &#8220;User Password&#8221;<br \/>\n&#8216;<br \/>\n&#8216;Label2<br \/>\n&#8216;<br \/>\nMe.Label2.Location = New System.Drawing.Point(88, 136)<br \/>\nMe.Label2.Name = &#8220;Label2&#8221;<br \/>\nMe.Label2.Size = New System.Drawing.Size(88, 24)<br \/>\nMe.Label2.TabIndex = 5<br \/>\nMe.Label2.Text = &#8220;HP Group&#8221;<br \/>\n&#8216;<br \/>\n&#8216;Label3<br \/>\n&#8216;<br \/>\nMe.Label3.Location = New System.Drawing.Point(88, 200)<br \/>\nMe.Label3.Name = &#8220;Label3&#8221;<br \/>\nMe.Label3.Size = New System.Drawing.Size(88, 24)<br \/>\nMe.Label3.TabIndex = 6<br \/>\nMe.Label3.Text = &#8220;Sample Result&#8221;<br \/>\n&#8216;<br \/>\n&#8216;Form1<br \/>\n&#8216;<br \/>\nMe.AutoScaleBaseSize = New System.Drawing.Size(5, 13)<br \/>\nMe.ClientSize = New System.Drawing.Size(616, 374)<br \/>\nMe.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label3, Me.Label2, Me.Label1, Me.Button2, Me.hpgroup, Me.password, Me.TextBox1, Me.Button1})<br \/>\nMe.Name = &#8220;Form1&#8221;<br \/>\nMe.Text = &#8220;Form1&#8221;<br \/>\nMe.ResumeLayout(False)<\/p>\n<p>End Sub<\/p>\n<p>#End Region<\/p>\n<p>Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br \/>\nDim conn As New ADODB.Connection()<br \/>\nDim rs As New ADODB.Recordset()<\/p>\n<p>TextBox1.Text = &#8220;busy&#8230;&#8221;<br \/>\nApplication.DoEvents()<\/p>\n<p>conn.Open(&#8220;DRIVER=HP3000 Data Access Driver;&#8221; &amp; _<br \/>\n&#8220;2DriverTable=;&#8221; &amp; _<br \/>\n&#8220;Database0=MSCARD.MM.MINISOFT,DO-ALL,N,1;&#8221; &amp; _<br \/>\n&#8220;2HostTable=Customers;&#8221; &amp; _<br \/>\n&#8220;Server=192.168.23.70;&#8221; &amp; _<br \/>\n&#8220;Server Port=2185;&#8221; &amp; _<br \/>\n&#8220;Jobname=MSJOB;&#8221; &amp; _<br \/>\n&#8220;User=MGR;&#8221; &amp; _<br \/>\n&#8220;User Password=&#8221; &amp; password.Text &amp; &#8220;;&#8221;&amp; _<br \/>\n&#8220;Group=&#8221; &amp; hpgroup.Text &amp; &#8220;;&#8221; &amp; _<br \/>\n&#8220;Account=MINISOFT&#8221;)<\/p>\n<p>rs.Open(&#8220;SELECT * FROM CUSTOMER&#8221;, conn)<\/p>\n<p>rs.MoveFirst()<\/p>\n<p>TextBox1.Text = CStr(rs.Fields(2).Value)<\/p>\n<p>End Sub<\/p>\n<p>Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click<\/p>\n<p>Dim conn As New OdbcConnection()<\/p>\n<p>Dim myConnString As String = _<br \/>\n&#8220;DRIVER=HP3000 Data Access Driver;&#8221; &amp; _<br \/>\n&#8220;2DriverTable=;&#8221; &amp; _<br \/>\n&#8220;Database0=MSCARD.MM.MINISOFT,DO-ALL,N,1;&#8221; &amp; _<br \/>\n&#8220;2HostTable=Customers;&#8221; &amp; _<br \/>\n&#8220;Server=192.168.23.70;&#8221; &amp; _<br \/>\n&#8220;Server Port=2185;&#8221; &amp; _<br \/>\n&#8220;Jobname=MSJOB;&#8221; &amp; _<br \/>\n&#8220;User=MGR;&#8221; &amp; _<br \/>\n&#8220;User Password=&#8221; &amp; password.Text &amp; &#8220;;&#8221; &amp; _<br \/>\n&#8220;Group=&#8221; &amp; hpgroup.Text &amp; &#8220;;&#8221; &amp; _<br \/>\n&#8220;Account=MINISOFT&#8221;<\/p>\n<p>Dim mySelectCommandText As String = _<br \/>\n&#8220;SELECT * FROM CUSTOMER&#8221;<\/p>\n<p>TextBox1.Text = &#8220;busy&#8230;&#8221;<br \/>\nApplication.DoEvents()<\/p>\n<p>conn.ConnectionString = myConnString<\/p>\n<p>conn.Open()<\/p>\n<p>Dim myCommand As New OdbcCommand(mySelectCommandText, conn)<br \/>\nDim myReader As OdbcDataReader<br \/>\nmyReader = myCommand.ExecuteReader()<br \/>\nIf myReader.Read() Then<br \/>\nTextBox1.Text = myReader.GetString(2)<br \/>\nElse<br \/>\nTextBox1.Text = &#8220;error&#8221;<br \/>\nEnd If<\/p>\n<p>End Sub<br \/>\nEnd Class<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Download the sample: [HTTP] &nbsp; Imports Microsoft.Data.Odbc Public Class Form1 Inherits System.Windows.Forms.Form #Region &#8221; Windows Form Designer generated code &#8221; Public Sub New() MyBase.New() &#8216;This call is required by the Windows Form Designer. InitializeComponent() &#8216;Add any initialization after the InitializeComponent() call End Sub &#8216;Form overrides dispose to clean up the component list. Protected Overloads [&hellip;]<\/p>\n","protected":false},"author":75,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[54,63],"tags":[],"_links":{"self":[{"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/posts\/2327"}],"collection":[{"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/users\/75"}],"replies":[{"embeddable":true,"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/comments?post=2327"}],"version-history":[{"count":3,"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/posts\/2327\/revisions"}],"predecessor-version":[{"id":2331,"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/posts\/2327\/revisions\/2331"}],"wp:attachment":[{"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/media?parent=2327"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/categories?post=2327"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/tags?post=2327"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}