ho trovato un codice molto interessante però è in C, vorrei trasformarlo in VB.NET....
DI SEGUITO RIPORTO ANCHE IL CODICE XAML, ESSENDO UN'APPLICAZIONE WPF
App.xaml
Window1.xaml.cscodice:<Application x:Class="DataBind.App" xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="Window1.xaml" > <Application.Resources> </Application.Resources> </Application>
Window1.xamlcodice:using System; using System.Data; using MySql.Data.MySqlClient; namespace DataBind { /// <summary> /// Interaction logic for Window1.xaml /// </summary> public partial class Window1 : System.Windows.Window { public Window1() { InitializeComponent(); DataTable contentsTable = new DataTable(); //Set the connection String String connString = "server=127.0.0.1;uid=root;pwd=password;database=contents;"; //Set the query String query = "SELECT assetno, item, descr, serialno, purchfrom, manuf FROM contents"; // Fill the Set with the data using (MySqlConnection conn = new MySqlConnection(connString)) { //Passing the query and connection String MySqlDataAdapter da = new MySqlDataAdapter(query, conn); da.Fill(contentsTable); } // Set the Data Context DataContext = contentsTable; } } }
codice:<Window x:Class="DataBind.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Data Binding Example" Height="220" Width="300" WindowStartupLocation="CenterScreen"> <Grid> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> <RowDefinition/> <RowDefinition/> <RowDefinition/> <RowDefinition/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="75"/> <ColumnDefinition/> </Grid.ColumnDefinitions> <Label>Assetno:</Label> <TextBox Grid.Column="1" Text="{Binding Path=assetno}"/> <Label Grid.Row="1">Item:</Label> <TextBox Grid.Row="1" Grid.Column="1" Text="{Binding item}"/> <Label Grid.Row="2">Description:</Label> <TextBox Grid.Row="2" Grid.Column="1" Text="{Binding descr}"/> <Label Grid.Row="3">Serialno:</Label> <TextBox Grid.Row="3" Grid.Column="1" Text="{Binding serialno}"/> <Label Grid.Row="4">Purch. from:</Label> <TextBox Grid.Row="4" Grid.Column="1" Text="{Binding purchfrom}"/> <Label Grid.Row="5">Manuf:</Label> <TextBox Grid.Row="5" Grid.Column="1" Text="{Binding manuf}"/> </Grid> </Window>

Rispondi quotando