Pho3nix
The Legend
Even with throwaway code, stop using variable names like "dt".
True. Still working on that habit.
South Africa’s biggest forum. Discuss, discover, and connect with thousands of members.
Even with throwaway code, stop using variable names like "dt".
sqlsc = "CREATE TABLE " + "[" + tableName + "]"+"(";
for (int i = 0; i < table.Columns.Count; i++)
{
sqlsc += "[" + table.Columns.ColumnName + "] ";
if (table.Columns.DataType.ToString().Contains("System.Int32"))
sqlsc += " [int] ";
else if (table.Columns.DataType.ToString().Contains("System.DateTime"))
sqlsc += " [datetime] ";
else
sqlsc += " nvarchar(500)";
sqlsc += ",";
}
OleDbDataAdapter A = new OleDbDataAdapter();
For the love of god man, at least use stringbuilders when concatenating strings. You'll thank me later :3
using (SqlConnection connection = new SqlConnection(connectionString))
{
if (connection.State == ConnectionState.Closed)
connection.Open();
COde Nazi's code Nazi's everywhere!
I don't think that you need to check the connection string state and open it afterwards when you are using the "using" command.
"A"? Really now?
I think you need to clean up a lot of code once you got this working.
+1
using (SqlConnection conn = new SqlConnection(connectionString))
using (SqlCommand cmd = new SqlCommand("sp_submit", conn))
{
conn.Open();
cmd.CommandType = CommandType.StoredProcedure;
var param = cmd.Parameters.AddWithValue("@myTable", table);
param.SqlDbType = SqlDbType.Structured;
result = cmd.ExecuteNonQuery();
}
