@@ -43,6 +43,7 @@ private string OpenFilePath
43
43
this . SelectedFields = null ;
44
44
this . openFilePath = value ;
45
45
this . changeFieldsMenuStripButton . Enabled = false ;
46
+ this . getSQLCreateTableScriptToolStripMenuItem . Enabled = false ;
46
47
this . recordCountStatusBarLabel . Text = "0" ;
47
48
this . totalRowCountStatusBarLabel . Text = "0" ;
48
49
this . MainDataSource . Clear ( ) ;
@@ -56,6 +57,7 @@ private string OpenFilePath
56
57
{
57
58
this . Text = string . Concat ( "Open File: " , value ) ;
58
59
this . changeFieldsMenuStripButton . Enabled = true ;
60
+ this . getSQLCreateTableScriptToolStripMenuItem . Enabled = true ;
59
61
}
60
62
}
61
63
}
@@ -671,8 +673,8 @@ private void mainGridView_DataBindingComplete(object sender, DataGridViewBinding
671
673
private void OpenNewFile ( string filePath )
672
674
{
673
675
this . OpenFilePath = filePath ;
674
- this . offsetTextBox . Text = DefaultOffset . ToString ( ) ;
675
- this . recordCountTextBox . Text = DefaultRowCount . ToString ( ) ;
676
+ this . offsetTextBox . Text = string . IsNullOrWhiteSpace ( this . offsetTextBox . Text ) ? DefaultOffset . ToString ( ) : this . offsetTextBox . Text ;
677
+ this . recordCountTextBox . Text = string . IsNullOrWhiteSpace ( this . recordCountTextBox . Text ) ? DefaultRowCount . ToString ( ) : this . recordCountTextBox . Text ;
676
678
677
679
this . OpenFieldSelectionDialog ( ) ;
678
680
}
@@ -833,16 +835,21 @@ private void GetSQLCreateTableScriptToolStripMenuItem_Click(object sender, Event
833
835
834
836
try
835
837
{
836
- var dataset = new DataSet ( ) ;
838
+ if ( this . mainDataSource ? . Columns . Count > 0 )
839
+ {
840
+ var dataset = new DataSet ( ) ;
837
841
838
- this . mainDataSource . TableName = tableName ;
839
- dataset . Tables . Add ( this . mainDataSource ) ;
842
+ this . mainDataSource . TableName = tableName ;
843
+ dataset . Tables . Add ( this . mainDataSource ) ;
840
844
841
- var scriptAdapter = new CustomScriptBasedSchemaAdapter ( ) ;
842
- string sql = scriptAdapter . GetSchemaScript ( dataset , false ) ;
845
+ var scriptAdapter = new CustomScriptBasedSchemaAdapter ( ) ;
846
+ string sql = scriptAdapter . GetSchemaScript ( dataset , false ) ;
843
847
844
- Clipboard . SetText ( sql ) ;
845
- MessageBox . Show ( this , "Create table script copied to clipboard!" , "Parquet Viewer" , MessageBoxButtons . OK , MessageBoxIcon . Information ) ;
848
+ Clipboard . SetText ( sql ) ;
849
+ MessageBox . Show ( this , "Create table script copied to clipboard!" , "Parquet Viewer" , MessageBoxButtons . OK , MessageBoxIcon . Information ) ;
850
+ }
851
+ else
852
+ MessageBox . Show ( this , "Please select some fields first to get the SQL script" , "Parquet Viewer" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
846
853
}
847
854
catch ( Exception ex )
848
855
{
0 commit comments