Hello
I've posted a few days ago how to get my data in a SQL database and show it in a datagridview. I found out how to do this rather quickly however I've been asked if I can add a button to my form and be able to print my datagridview.
My code to show the datagrid:
Dim id As String
Dim prognaam As String
Dim fout As String
Dim sdrFoutregistratie As SqlClient.SqlDataReader
Dim tblFoutvermelding As New DataTable
Dim scmdOpenDatabase As New SqlClient.SqlCommand
tblFoutvermelding.Columns.Add("Id")
tblFoutvermelding.Columns.Add("Prognaam")
tblFoutvermelding.Columns.Add("Fout")
cnnFoutvermeldingSQL.Open()
scmdOpenDatabase.Connection = cnnFoutvermeldingSQL
scmdOpenDatabase.CommandText = "SELECT Id, Prognaam, fout FROM Registratietabel ORDER BY Id"
sdrFoutregistratie = scmdOpenDatabase.ExecuteReader
Do While sdrFoutregistratie.Read
id = sdrFoutregistratie.GetValue(0).ToString
prognaam = sdrFoutregistratie.GetValue(1).ToString
fout = sdrFoutregistratie.GetValue(2).ToString
tblFoutvermelding.Rows.Add()
tblFoutvermelding.Rows(tblFoutvermelding.Rows.Count - 1)("Id") = id
tblFoutvermelding.Rows(tblFoutvermelding.Rows.Count - 1)("Prognaam") = prognaam
tblFoutvermelding.Rows(tblFoutvermelding.Rows.Count - 1)("Fout") = fout
Loop
DataGridView1.DataSource = tblFoutvermelding
cnnFoutvermeldingSQL.Close()
So my question is how i'm able to add a print function to the form.