Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I connect to MS DataBase #133

Closed
hyousefGopher opened this issue Jan 23, 2020 · 8 comments
Closed

How can I connect to MS DataBase #133

hyousefGopher opened this issue Jan 23, 2020 · 8 comments
Labels

Comments

@hyousefGopher
Copy link

hyousefGopher commented Jan 23, 2020

I'm connected to MS Access database using julia odbc as below:

db=ODBC.DSN("Driver={Microsoft Access Driver (*.mdb, *.accdb)}; DBQ=C:/Users/hasan.yousef/Documents/myDB.accdb")

I'm using evcxr_jupyter

How can I do the same using Rust.

image

@Koka
Copy link
Owner

Koka commented Jan 23, 2020

Hello, thanks for your question. I've personally never touched jupyter, but your screenshot shows that you're missing some use something; statements. Feel free to refer to examples dir in this repo to see how the connection is done.

@Koka Koka added the question label Jan 23, 2020
@hyousefGopher
Copy link
Author

hyousefGopher commented Jan 23, 2020

Thanks @Koka
I made some changes, and got the below:

image

Moreover, What shall I write instead of: TestDataSource, do I need to write the same string I used in Julia, i.e.
let conn = env.connect("Driver={Microsoft Access Driver (*.mdb, *.accdb)}; DBQ=C:/Users/hasan.yousef/Documents/ais_sc.accdb", "", "").unwrap();

@Koka
Copy link
Owner

Koka commented Jan 23, 2020

I guess you could use env.connect_with_connection_string("Your connection string as in julia")

@Koka
Copy link
Owner

Koka commented Jan 23, 2020

About that type error - try to remove type declaration on env variable

@hyousefGopher
Copy link
Author

hyousefGopher commented Jan 23, 2020

I got:

image

And:

image
image

@hyousefGopher
Copy link
Author

To avoid confusing I moved out of Jupyter and testing in Code:

use odbc::*;

fn main() {
    println!("Hello, world!");
    env_logger::init();
    let mut env = create_environment_v3().map_err(|e| e.unwrap()).unwrap();
    let conn = env.connect_with_connection_string("Driver={Microsoft Access Driver (*.mdb, *.accdb)};
 DBQ=C:/Users/hasan.yousef/Documents/ais_sc.accdb");
}

But got:

    Finished dev [unoptimized + debuginfo] target(s) in 0.86s
     Running `target\debug\db.exe`
Hello, world!
[2020-01-23T16:35:09Z WARN  odbc::result] State: HY000, Native error: 63, Message: [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x2
224 Thread 0x53e4 DBC 0x51eb00b8                                                              Jet'.
[2020-01-23T16:35:09Z WARN  odbc::result] State: HY000, Native error: 63, Message: [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x2
224 Thread 0x53e4 DBC 0x51eb00b8    

@Koka
Copy link
Owner

Koka commented Jan 23, 2020

It's some db specific error from your driver, can't help here

@hyousefGopher
Copy link
Author

Thanks, may be this the issue, I'll check it in office next week.

@Koka Koka closed this as completed May 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants