最近工作电脑装完win10后,之前使用的codeSmith安装不了,索性自己写一个。
界面比较简单,如下图:
第一行为Oracle数据库的连接字符串。连接成功后,填充表到第4行的下拉列表中。
第二行为实体类命名空间。
第三行为保存生成类、xml文件选择文件夹。
1 private void btnConnect_Click(object sender, RoutedEventArgs e) 2 { 3 try 4 { 5 using (OracleConnection conn = new OracleConnection()) 6 { 7 conn.ConnectionString = txtConnStr.Text; 8 9 using (OracleCommand cmd = conn.CreateCommand()) 10 { 11 cmd.CommandText = "select distinct table_name from user_tables order by table_name"; 12 13 DataTable dt = new DataTable(); 14 15 OracleDataAdapter adapter = new OracleDataAdapter(); 16 adapter.SelectCommand = cmd; 17 18 adapter.Fill(dt); 19 20 cbTables.DisplayMemberPath = "TABLE_NAME"; 21 cbTables.SelectedValuePath = "TABLE_NAME"; 22 cbTables.ItemsSource = dt.DefaultView; 23 24 } 25 26 MessageBoxShow("连接成功!"); 27 28 } 29 } 30 catch 31 { 32 MessageBoxShow("连接失败!"); 33 } 34 }