DSN with ASP.NET

shelleyqfrossq

New Member
Can anyone show me an example of using a dsn with ASP.NET?<BR><BR>The book I have says you can just put it in the connection string as "dsn=whatever". When I try this I receive an error saying "Unknown connection option in connection string: dsn". <BR><BR>Any ideas?<BR><BR>Thanks"dsn=whatever" is fine. The problem is in the "whatever" variable. What's the text in this variable look like?<BR><BR>What lanuage are you using? Languages can be case sensitive.<BR>Try "DSN=mydsn"<BR><BR>What are you using sql or oledb ...<BR>oledb written in VB.NET<BR>oConnection = New OleDbConnection("DSN=mydsn;")<BR>sql written in VB.NET<BR>oConnection = New SQLDbConnection("DSN=mydsn;")<BR><BR>Aaron<BR><BR>&nbsp;<BR>'set up connection<BR>dim myConnection as new OleDbConnection("Provider = ????;" & _<BR> "DSN=NISLDATA") <BR><BR>Data is Visual FoxPro DBC<BR>I can not get the Provider correct?<BR>the closest I can get is an ISAM Error.<BR>Can AnyOne help?I dunno what they've done, but they obvoiusly know something I don't, 'cause I've never been able to get a DSN to work via OleDb. Perhaps someone can enlighten us.<BR><BR>I *have* however, found that DSNs work beautifully when using ODCB.<BR><BR>I downloaded and installed Microsoft.Data.Odbc, then created a <BR>new connection like so...<BR><BR>dim Conn as New OdbcConnection("DSN=MyDSN")<BR><BR>And it all worked smashingly.I get <BR><BR>Compilation Error <BR>Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. <BR><BR>Compiler Error Message: BC30002: Type is not defined: 'OdbcConnection'<BR><BR>Source Error:<BR><BR> <BR><BR>Line 10: <BR>Line 11: 'set up connection<BR>Line 12: dim myConnection as New OdbcConnection("DSN=NISLData") <BR><BR>Assume I need Microsoft.Data.Odbc<BR>I can't find on MSN Downloads Do you remember where you found it?<BR><BR>Thanks for the help.<BR> <BR>http://msdn.microsoft.com/downloads/default.asp?URL=/downloads/sample.asp?url=/MSDN-FILES/027/001/668/msdncompositedoc.xmlI did find that site. I did have that dll on my computer and still get the error. Any Ideas?<BR><BR>I put Microsoft.Data.Odbc.dll in my C:inetpubwwwrootin directory.<BR><BR>Now, here is the page:<BR><BR><%@ Assembly Name="Microsoft.Data.Odbc" %><BR><%@ Page Language="VB" debug="true" %><BR><%@ Import Namespace="System.Data" %><BR><%@ Import Namespace="Microsoft.Data.Odbc" %><BR><BR><script runat="server"><BR> Sub Page_Load(obj As Object, e AS EventArgs)<BR> <BR> dim Conn as New OdbcConnection("DSN=MyDSN")<BR> <BR> dim Cmd As New OdbcCommand _<BR> ("SELECT MyField FROM MyTable", Conn)<BR> <BR> dim objReader As OdbcDataReader<BR> <BR> Conn.Open<BR> objReader = Cmd.ExecuteReader<BR> <BR> While objReader.Read<BR> Response.Write(objReader.GetString(0) & "<BR>")<BR> End While<BR> <BR> Conn.Close()<BR> End Sub<BR></script><BR><BR><html><body><BR><BR></body></html><BR><BR>And presto! It worked beautifully.<%@ Assembly Name="Microsoft.Data.Odbc" %><BR><%@ Page Language="VB" %><BR><%@ Import Namespace="System.Data" %><BR><%@ Import Namespace="Microsoft.Data.Odbc" %><BR><BR><script runat="server"><BR>Sub Page_Load(obj As Object, e AS EventArgs)<BR><BR>dim Conn as New OdbcConnection("DSN=MyDSN")<BR><BR>dim Cmd As New OdbcCommand _<BR>("SELECT MyField FROM MyTable", Conn)<BR><BR>dim objReader As OdbcDataReader<BR><BR>Conn.Open<BR>objReader = Cmd.ExecuteReader<BR><BR>While objReader.Read<BR>Response.Write(objReader.GetString(0) & "<br>")<BR>End While<BR><BR>Conn.Close()<BR>End Sub<BR></script><BR><BR><html><body><BR><BR></body></html>This is what it did error is at bottom. I tried usind DSN and Directly pointing to the data file. Also tried dll in two places. Debug command does not seem to work?<BR><BR>' Access with <BR>' http://jimsbox/tyaspnet/day9/listing9.8C.aspx<BR>' Microsoft.Data.Odbc.dll in in //jimsbox/tyaspnet/day9/ also tried<BR>' c:inetpubwwwrootin<BR><%@ Assembly Name="Microsoft.Data.Odbc" %> <BR><%@ Page Language="VB" Debug="true" %> <BR><%@ Import Namespace="System.Data" %> <BR><%@ Import Namespace="Microsoft.Data.Odbc" %> <BR><BR><script runat="server"> <BR>Sub Page_Load(obj As Object, e AS EventArgs) <BR><BR>dim Conn as New OdbcConnection("DSN=SoccerData") <BR>'dim Conn as New OdbcConnection("Provider=Microsoft.data.odbc;" & _<BR>' "Data Source=C:vfp7appssoccer2000data
isldata.dbc")<BR><BR>dim Cmd As New OdbcCommand _ <BR>("SELECT lname FROM Names", Conn) <BR><BR>dim objReader As OdbcDataReader <BR><BR>Conn.Open <BR>objReader = Cmd.ExecuteReader <BR><BR>While objReader.Read <BR>Response.Write(objReader.GetString(0) & "<BR>") <BR>End While <BR><BR>Conn.Close() <BR>End Sub <BR></script> <BR><BR><html><body> <BR><BR></body></html> <BR><BR><BR><BR><BR>Server Error in '/' Application.<BR>--------------------------------------------------------------------------------<BR><BR>File or assembly name System, or one of its dependencies, was not found. <BR>Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. <BR><BR>Exception Details: System.IO.FileNotFoundException: File or assembly name System, or one of its dependencies, was not found.<BR><BR><BR>Stack Trace: <BR><BR><BR>[FileNotFoundException: File or assembly name System, or one of its dependencies, was not found.]<BR> ASP.Listing9_8b_aspx.Page_Load(Object obj, EventArgs e) +0<BR> System.Web.UI.Control.OnLoad(EventArgs e) +67<BR> System.Web.UI.Control.LoadRecursive() +73<BR> System.Web.UI.Page.ProcessRequestMain() +394<BR><BR> <BR>Debug=true ...No qoutes. Then see what it gives you...File or assembly name System, or one of its dependencies, was not found. <BR>Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. <BR><BR>Exception Details: System.IO.FileNotFoundException: File or assembly name System, or one of its dependencies, was not found.<BR><BR>Source Error: <BR><BR>The source code which generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, and then re-request the URL:<BR><BR>1) Add a "Debug=true" directive at the top of the file which generated the error. Example:<BR><BR> <%@ Page Language="C#" Debug="true" %><BR><BR> this is the code:<BR>' Access with <BR>' http://jimsbox/tyaspnet/day9/listing9.8B.aspx<BR><%@ Assembly Name="Microsoft.Data.Odbc" %> <BR><%@ Page Language="VB" debug=true %> <BR><%@ Import Namespace="System.Data" %> <BR><%@ Import Namespace="Microsoft.Data.Odbc" %> <BR><BR>doesn't seem to matter if there are quotes or not around true<BR>Hmmm...Where is your Microsoft.Data.Odbc.dll?' Access with <BR>' http://jimsbox/tyaspnet/day9/listing9.8B.aspx<BR><BR>I have tried bin in tyaspnet/day9/ and<BR>tyaspnet/day9/bin/<BR>and c:inetpubwwwrootin<BR>all with same results<BR>Tried ????.aspx file in c:inetpubwwwroot with<BR>dll in d:inetpubwwwrootin<BR><BR>Same results<BR>It was dumb. I finally realized I was working with the beta copy of asp.net from the book. I downloaded the current version and service pack 1 and whala it works.<BR><BR>Thanks for you help.<BR><BR>
 
Back
Top