Tech
Forums
Jobs
Books
Events
Videos
Conference
Annual Conference
Bcrypt
Ai Conference
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
4
Reply
How to define common odbc connection??
Ask a question
Ask a question
Upload Source Code:
Select only zip and rar file.
Senthil Gopi
11y
2.1k
1
Reply
Hi
I'm new to .net , I'm creating a new windows application, i have 3 forms in it, all the forms will have related to database execution, so every time do i need to define same set of odbc connection or there any function to create it as common and can be called by the all the forms??
OdbcConnection dbcon = new OdbcConnection("Driver={IBM DB2 ODBC DRIVER};DBALIAS=TEST;Uid=db2admin;Pwd=xingmpeg;");
OdbcCommand cmd;
OdbcDataAdapter oda;
DataSet ds;
dbcon.Open();
string dbcmd = "Select * from tbl_login where u_name = '" + textBox1.Text + "'";
cmd = new OdbcCommand(dbcmd, dbcon);
oda = new OdbcDataAdapter();
ds = new DataSet();
oda.SelectCommand = cmd;
oda.Fill(ds);
dbcon.Close();
Post
Reset
Cancel
Answers (
4
)
Next Recommended Forum
Difference between OLEDB Provider and SqlClient
Purpose of connection pooling in ADO.NET