Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > DB Connection with ODBC ASP.NET

Reply
Thread Tools

DB Connection with ODBC ASP.NET

 
 
=?Utf-8?B?TUFUVA==?=
Guest
Posts: n/a
 
      10-25-2006
Using ASP.NET I would like to connect to a database using a System DSN in
ODBC. Will this allow me to make the connection without having to specify in
the code the server, user, password...etc...? Could someone please give me
an example of a simple query using this method
Thanks
MATT
 
Reply With Quote
 
 
 
 
sloan
Guest
Posts: n/a
 
      10-25-2006
http://www.connectionstrings.com/

this has a
DSN
ODBC

since I don't connect that way, I'm not sure if it has exactly what you
want.

but its a hint.


"MATT" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Using ASP.NET I would like to connect to a database using a System DSN in
> ODBC. Will this allow me to make the connection without having to specify

in
> the code the server, user, password...etc...? Could someone please give

me
> an example of a simple query using this method
> Thanks
> MATT



 
Reply With Quote
 
 
 
 
=?Utf-8?B?TUFUVA==?=
Guest
Posts: n/a
 
      10-25-2006
Thanks for your reply. I guess the problem is not with my connection string.
My Code is below.
1) i get an error at the SqlDR = SqlDT.rows(0)
error: "System.NullReferenceException: Object reference not set to an
instance of an object."

2) Is there a way to connect to the DB without having to code in the
username, password, database, etc.... as in, use the ODBC DataSource Name?


CODE:

Dim DbConn As New
SqlConnection("server=localhost\SQLEXPRESS;databas e=LoginTest;user=sa;pwd=mattsa")
Dim SqlStr As String = "Select * from Users where UName = 'user' "

Dim SqlCmd As New SqlCommand(SqlStr, DbConn)

Dim SqlDA As New SqlDataAdapter(SqlCmd)

Dim sqlDS As New DataSet("Users")
SqlDA.Fill(sqlDS)

Dim SqlDT As DataTable
SqlDT = sqlDS.Tables("Users")

Dim SqlDR As DataRow
SqlDR = SqlDT.Rows(0) <--PROBLEM IS HERE!!!!

 
Reply With Quote
 
=?Utf-8?B?TUFUVA==?=
Guest
Posts: n/a
 
      10-25-2006
Update:
I am able to connect to the DB now. I found my mistakes.

Still, i would like to be able to connect using the ODBC DSN without coding
the password/user

This is my code:

WORKS: Dim DbConn As New
SqlConnection("server=Matthew\SQLEXPRESS;database= LoginTest;user=logintest;pwd=test")

DOES NOT WORK: Dim DbConn As New ODBCConnection("DSN=LoginTest;")

error: User '' is not associated with a trusted SQL Connection

why can't it use the credentials i set up in the "LoginTest" DSN? Is there
another way?

"sloan" wrote:

> http://www.connectionstrings.com/
>
> this has a
> DSN
> ODBC
>
> since I don't connect that way, I'm not sure if it has exactly what you
> want.
>
> but its a hint.
>
>
> "MATT" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Using ASP.NET I would like to connect to a database using a System DSN in
> > ODBC. Will this allow me to make the connection without having to specify

> in
> > the code the server, user, password...etc...? Could someone please give

> me
> > an example of a simple query using this method
> > Thanks
> > MATT

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: The ODBC resource DLL is a different version than the ODBC driver manager beenthere Computer Support 12 10-17-2006 07:11 PM
Re: The ODBC resource DLL is a different version than the ODBC driver manager tenkbabe@yahoo.com Computer Support 0 10-16-2006 01:11 PM
ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0xffc Thread 0x228 DBC 0x437b94 Jet'. ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr bazzer ASP .Net 0 03-30-2006 03:16 PM
ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x8fc Thread 0x934 DBC 0x437b94 Jet'. ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr bazzer ASP .Net 1 03-24-2006 04:20 PM
ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x8fc Thread 0x934 DBC 0x437b94 Jet'. ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr bazzer ASP .Net 0 03-24-2006 02:22 PM



Advertisments