Table Creation using SQL client and a custom class

  • Thread starter Thread starter JohnDBCTX
  • Start date Start date
J

JohnDBCTX

Guest
Hello,

I have this code snippet below:

Namespace Emails
Public Class EmailTables
Public Property EmailID() As Integer
Public Property Email() As String

Public ReadOnly Property EmailArray() As String()
Get
Return {EmailID, Email}
End Get
End Property

End Class

End Namespace


Imports SQL_App_One.Emails

Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'DBZDataSet.EmployeeSales' table. You can move, or remove it, as needed.
Me.EmployeeSalesTableAdapter.Fill(Me.DBZDataSet.EmployeeSales)

End Sub

Private Sub CreateTableFromSQLButton_Click(sender As Object, e As EventArgs) Handles CreateTableFromSQLButton.Click
Dim SQLConnX As New SqlClient.SqlConnection
Dim SQLDBX As New SqlClient.SqlDataAdapter
Dim SQLZZZ As New SqlClient.SqlParameter
Dim SQLDgv As New DataGridView
Dim SQLTblAdpt As New DataTable
Dim SQLDSet As New DataSet
Dim SQLBindSrc As New BindingSource
Dim SQLCmd As New SqlClient.SqlCommand
Dim clsEm As New EmailTables


SQLConnX.ConnectionString = "Data Source=DESKTOP-ALKNN6N;Initial Catalog=DBZ;Integrated Security=True"

SQLCmd = New SqlClient.SqlCommand("CREATE TABLE tblEmails(" & clsEm.EmailID & " INT NULL, " & clsEm.Email & ", VARCHAR(50) NULL)", SQLConnX)

SQLConnX.Open()

SQLCmd.ExecuteNonQuery()

SQLConnX.Close()


SQLDSet.DataSetName = "EmailListings"
SQLBindSrc.DataSource = SQLDSet
SQLBindSrc.DataMember = "EmailListings"






With SQLDgv
.Height = 500
.Width = 500
.Top = 100
.Left = 100
.DataSource = SQLBindSrc
End With





SQLDgv.Show()

SQLConnX.Close()

Me.Controls.Add(SQLDgv)


End Sub





End Class


I don't know how to explain this but what I want to perform is how to assign parameters of the custom public class to the text box cells of its data grid view control.



But first I need to declare some text box cells for its data grid view control. That needs to be initialized first prior to assigning its custom class parameters to them.

Regards,


JohnDBCTX



jp

Continue reading...
 
Back
Top