Write your own sqlhelper, please refer to the use of it
Using system;using system.collections.generic;using system.linq;using system.text;using System.Windows;using System.windows.controls;using system.windows.data;using system.windows.documents;using System.Windows.Input;using System.windows.media;using system.windows.media.imaging;using system.windows.navigation;using System.windows.shapes;using System.Data; Using System.data.sqlclient;namespace sqlhelper{///<summary>///Window1.xaml interactive logic///</summary> Public partial class Window1:window {public Window1 () {InitializeComponent (); The SQL private void Btnds_click (object sender, RoutedEventArgs e) {sqlhelpe) is used only to execute query results less than R.executenonqurey ("INSERT into t_student (name,age) VALUES (' Zhang San ',") ", new sqlparameter[0]); MessageBox.Show ("add success"); private void Btndataset_click (object sender, RoutedEventArgs e) {DataSet ds= Sqlhelper.execute DataSet("SELECT * from t_student where hobbit= ' @hobbit '", New Sqlparameter[]{new SqlParameter ("' @hobbit '", "hahaha")}) ; foreach (DataRow row in DS. Tables[0]. Rows) {String name = (string) row["name"]; MessageBox.Show (name); } } }}