Showing posts with label website. Show all posts
Showing posts with label website. Show all posts

Tuesday, March 27, 2012

Data source name not found and no default driver specified - When the website was publishe

ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

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.

Exception Details:System.Data.Odbc.OdbcException: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:

[OdbcException (0x80131937): ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified] System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode) +35 System.Data.Odbc.OdbcConnectionHandle..ctor(OdbcConnection connection, OdbcConnectionString constr, OdbcEnvironmentHandle environmentHandle) +131 System.Data.Odbc.OdbcConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) +98 System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup) +27 System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +47 System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105 System.Data.Odbc.OdbcConnection.Open() +37 DBConnection.open() +12 ASP.global_asax.Session_Start(Object sender, EventArgs e) +35 System.Web.SessionState.SessionStateModule.RaiseOnStart(EventArgs e) +2163182 System.Web.SessionState.SessionStateModule.CompleteAcquireState() +154 System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData) +542 System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +90 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42

ODBC version 3.526.1830.0
strconn ="DSN=testserver;uid=tester;pwd=tester;DATABASE=Test_Database"

I've Test_Database on 2 machines (same data in both machines), one is in SQL 2005 server and another one is in SQL 2000 server.
When the website was published, it can't work. (with both database). But it work in debug mode in Visual Studio2005.

The website can't work when use ODBC connection but it work when use SqlClient.

Help me solve this problem please. T_T

Thanks in advance,

Did you create the ODBC DSN in your local machine?|||Yes sir , I've use ODBC while I develop this website. It can run in debug mode sir !|||

Ok, just let me know if you are getting this error on localhost or on a hosting server?

Also don't call me SirSmile

|||

I get this error nn localhost.

Database is on localhost(SQL2005) and other one is on another machine(SQL2000).

|||

Ok, check

www.connectionstrings.com

And make sure your connectionstring is correct.

Regards

|||

Yeah , It's resolved.

I added wrong DSN. I added it in User DSN. T_T

So I add new DSN in File DSN and the website work.

Thanks for your advice,

Regards,

|||

buabanz:

So I add new DSN in File DSN and the website work.

Oh sorry, I've added it in System DSN.

sql

Thursday, March 22, 2012

Data retrieving or querying problem

Hi, I am using visual web developer 2005 express edition and Microsoft SQL 2005 to develop a fast-food ordering website and I am having trouble in retrieving data from a database table into a form. Can some one please teach me the way to write the syntax forretrieving or selecting a inserted value from the database? I have only know the syntax to insert data value from a form which is something like this:

'Create a New Connection to our daabase

Dim testAs SqlDataSource =New SqlDataSource()

test.ConnectionString = ConfigurationManager.ConnectionStrings(

"Connectionstring1").ToString'This is the SQL Insert Command

test.InsertCommand =

"Insert into Customer([Initial],[Correspondent_Name],[Correspondent_No],[Payment_Type]) VALUES (@.Initial,@.Correspondent_Name,@.Correspondent_No,@.Payment_Type)"'Each of this insert a value into the appropriate command

test.InsertParameters.Add(

"Initial", DropDownList4.SelectedValue)'This is the selected "Initial" DropDownList value

test.InsertParameters.Add(

"Correspondent_Name", TextBox10.Text)'This is the Correspondent_Name value

test.InsertParameters.Add(

"Correspondent_No", TextBox3.Text)'This is correspondent_no value

test.InsertParameters.Add(

"Payment_Type","Pay upon delivery")'This indicates that the payment is made with credit card

test.Insert()

But I have no idea the syntax to retrieve a data. Please help me with this matter as it is important to me. Thanks in advance!

Regards,

Ivan

Hi,

There are many ways to retrieve data from a database table into a form. It depends on what kind of controls would you like to bound with.

If you want to display the data in a table, the easist way is to use a GridView control and assign its DataSourceID with the SqlDataSource control's ID.

Another way is to use DataView to retrieve the set of data.eg:

DataSourceSelectArguments ar =new DataSourceSelectArguments();DataView dv = (DataView)SqlDataSource1.Select(ar);this.TextBox1.Text = dv.Table.Rows[0]["CategoryName"].ToString();

In this way you can retrieve the value of any row any column manually.

Thanks.

|||

One of the ways how can you select data from database is this:

Imports System.Data.SqlClient

Dim test As SqlConnection = New SqlConnection()
test.ConnectionString = ConfigurationManager.ConnectionStrings("Connectionstring1").ConnectionString
Dim command As SqlCommand = test.CreateCommand()
command.CommandText = "SELECT * FROM Customer"
Dim GV1 As GridView = New GridView()
test.Open()
GV1.DataSource = command.ExecuteReader()
GV1.DataBind()
test.Close()
form1.Controls.Add(GV1)

Monday, March 19, 2012

Data problem when publishing website

I published my website directly to its production folder then opened Sql Express Management Studio and attached the ASPNETDB file to it in that folder. However, the location information displayed in the Databases window shows the file is actually mapped back to my development folder. ?

Has anyone else encountered this problem?

Yes, I did verify that I selected the correct location.

Okay, my mistake, it isn't actually mapped back to that file, it just names the database with the original path. Gotta wonder what genius thought that one up.

Friday, February 24, 2012

Data lost after INSERT command

I have a website that is used to enter dates from a calendar. For example, user A might go to the website and select 20 different days in January. When user A clicks on the Save button the dates are written to the database with an INSERT command. This works fine. However, when user B then goes through the same procedure, say selecting 5 dates that are in the set selected by user A, those dates are properly saved in the database but the rows containing user A's same 5 dates disappear. I suspect this is something simple but I'm new and ignorant. Please help.Are you sure that when User B selects dates that are in the set selected by User A you are not using an Update statement instead of an Insert statement?|||It would be very helpful if you would post the queries involved, as well as the table DDL.|||Thank you for taking the time to respond. I have a bit of code where I do a DELETE prior to doing the INSERT. Your question led me to examine my DELETE statement again, only to discover that I had made it too broad so that it was deleting all records having a particular date, not just the one of the user currently logged in. I will adopt the suggestion to include code in future postings. Thanks again.