Skip to content

create view error?? #399

@yuyang-ok

Description

@yuyang-ok
use tiberius::Client;
use tokio::net::TcpStream;
use tokio_util::compat::{Compat, TokioAsyncWriteCompatExt};
#[tokio::main]

async fn main() {
    let mut config = tiberius::Config::new();
    config.host("127.0.0.1");
    config.port(1433);
    config.authentication(tiberius::AuthMethod::sql_server("sa", "sfdewRE123"));
    config.database("test");
    config.trust_cert();
    let tcp = TcpStream::connect(config.get_addr()).await.unwrap();
    tcp.set_nodelay(true).unwrap();
    let mut client = Client::connect(config, tcp.compat_write()).await.unwrap();

    let err = client.execute("drop view dbo.test_view", &[]).await;
    if let Err(err) = err {
        println!("{}", err);
    }
    client
        .execute(
            r#"CREATE VIEW dbo.test_view AS
                SELECT
                    id,
                    name,
                    age,
                    email
                FROM
                    dbo.test_view_table"#,
            &[],
        )
        .await
        .unwrap();
}
warning: `abc-rust` (bin "abc-rust") generated 1 warning (run `cargo fix --bin "abc-rust"` to apply 1 suggestion)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.05s
     Running `target/debug/abc-rust`
Token error: 'Cannot drop the view 'dbo.test_view', because it does not exist or you do not have permission.' on server sqlpreview executing  on line 1 (code: 3701, state: 5, class: 11)

thread 'main' (723425) panicked at src/main.rs:34:10:
called `Result::unwrap()` on an `Err` value: Server(TokenError { code: 156, state: 1, class: 15, message: "Incorrect syntax near the keyword 'VIEW'.", server: "sqlpreview", procedure: "", line: 1 })
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

is this error relate to this library.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions