【发布时间】:2019-05-16 13:28:03
【问题描述】:
我需要从 C# 前端程序添加数据文件或调整数据文件的大小,而数据库中没有任何存储过程。
如何做到这一点?
Label1.text =Tablespace name
textbox1.text = location of datafile
textbox2.text = name of the datafile
这里是示例代码,但是当我运行它时出现错误:
ORA-00900: 无效的 SQL 语句
代码:
private void button1_Click(object sender, EventArgs e)
{
string sqla = @"alter tablespace '" + label1.Text + "' add datafile '" + textBox1.Text + "' size " + textBox2.Text +"M";
OracleConnection conn3 = new OracleConnection();
conn3.ConnectionString = connectform.connectionString;
conn3.Open();
OracleCommand cmd3 = new OracleCommand("sqla", conn3);
cmd3.CommandType = CommandType.Text;
cmd3.ExecuteNonQuery();
conn3.Close();
}
【问题讨论】:
-
Visual Studio 是一个 IDE。它不会执行您的代码。因此,
visual-studio标记仅用于与 Visual Studio 应用程序相关的问题,而不是您使用它编写的代码。 -
label1.Text、textBox1.Text、textBox2.Text的值是多少?完成的查询是什么?您没有清理这些输入字段的值,因此我假设您输入的某些文本会破坏您的查询。由于您没有提供,我怀疑有人可以帮助您。 -
为什么要将表空间名称放在单引号中(
alter tablespace 'tablespace_name'...)? -
你的内容真的是“数据文件的位置”和“数据文件的名称”吗?
-
为什么 sqla 在引号中:
OracleCommand cmd3 = new OracleCommand("sqla", conn3);