Hi, @Hector Agosto
This is the test example. Click button2 to read data and click button1 to show the Form1.
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
form1 = gcnew MyForm1(myAL);
form1->ShowDialog();
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
String^ connString = "Data Source = (localdb)\\ProjectModels; Initial Catalog = DataBase1; Integrated Security = True; Connect Timeout = 30; Encrypt = False; TrustServerCertificate = False; ApplicationIntent = ReadWrite; MultiSubnetFailover = False";
SqlConnection^ con = gcnew SqlConnection(connString);
con->Open();
String^ sqly = "select * from TestTable";
SqlCommand^ sqlCommand = gcnew SqlCommand(sqly, con);
SqlDataReader^ reader = sqlCommand->ExecuteReader();
mTable->Load(reader);
reader->Close();
con->Close();
for each (DataRow^ row in mTable->Rows)
{
myAL->Add(row["Notes"]->ToString());
}
}
Best regards,
Minxin Yu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.