Sql随处可见12个连接字符串

时间:2017-02-06 11:43:50

标签: sqlanywhere

我正在尝试将sql anywhere12数据库连接到我的.net项目,但在连接到数据库时我遇到了错误

“{”无效的连接字符串。解析连接参数字符串时出错\ r \ nParameter name:connectionString“}”

运行此代码时

private void btncon_Click(object sender, EventArgs e)
        {
         string connetionString = null;
            SAConnection connection;
            SACommand command;
            string sqla = null;

           // connetionString = "Data Source=SQL Anywhere 12 Demo;Initial Catalog=Demo2;User ID=dba;Password=sql";
            connetionString = "Driver={SQL Anywhere 12};ENG=demo12;UID=dba;PWD=sql;DBN=sql;LINKS=TCPIP(HOST=localhost)";

            sqla = "INSERT INTO  student(Rollnumber,Name) values('" + textBox1.Text + "','" + textBox2.Text + "')";

            connection = new SAConnection(connetionString);
            try
            {
                connection.Open();
                command = new SACommand(sqla, connection);
                command.ExecuteNonQuery();
                command.Dispose();
                connection.Close();
                MessageBox.Show(" ExecuteNonQuery in SqlCommand executed !!");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Can not open connection ! ");
            }

        }

实际上我对sql的任何地方都没有太多了解12个连接字符串请帮我解决这个错误

0 个答案:

没有答案