MS Access Database in web matrix.

Hi, 

I am not a professional web developer but my Hobby is developing website / Application.
 
I am yet to develop any dynamic website. I am in the process of doing so.

I Learnt how to develop asp.net files using web matrix and MSDN database. It was perfectly fine in this environment.

Now I am shifting towards, Web Matrix and MS ACCESS (.mdb) database. (In Web matrix web server).
No error is reported, But the database is not updated.

Any Suggestions?

Can any body help.

Thanks in Advance

Thiru
0
Thiru
9/12/2005 8:09:50 AM
asp.net.getting-started 91979 articles. 4 followers. Follow

1 Replies
546 Views

Similar Articles

[PageSpeed] 46

Thiru--

Regarding this...

 Thiru wrote:

...I Learnt how to develop asp.net files using web matrix and MSDN database. It was perfectly fine in this environment.... Now I am shifting towards, Web Matrix and MS ACCESS (.mdb) database. (In Web matrix web server).
No error is reported, But the database is not updated....Any Suggestions?... Can any body help.

...there is complete working sample on "Access Database" data access with all of the source code here...

http://www.WebLogicArts.com/DemoAccessDatabase01.aspx 

...and, as a quick sample, here is an excerpt of the code to demonstrate the principle...

        /// <summary>
        /// This method updates one row in the database.
        /// </summary>
        /// <param name="sender">This is the event source.</param>
        /// <param name="e">These are the event arguments.</param>
        private void UpdateOneButton_Click(object sender, System.EventArgs e)
        {
            const string COMMAND_FOR_UPDATE = "UPDATE SHIPPERS SET COMPANYNAME = @CompanyName, PHONE = @Phone WHERE SHIPPERID = @ShipperID";

            System.Data.OleDb.OleDbConnection myConnection = null;

            try
            {
                if (this.IsInt32(this.UpdateOneShipperIDTextbox.Text))
                {
                    int myShipperID = Convert.ToInt32(this.UpdateOneShipperIDTextbox.Text);

                    string myNewCompanyName = this.UpdateOneCompanyNameTextBox.Text;
                    myNewCompanyName = myNewCompanyName + string.Empty;
                    myNewCompanyName = myNewCompanyName.Trim();

                    if (myNewCompanyName.Length > COMPANY_MAX_LENGTH)
                    {
                        myNewCompanyName = myNewCompanyName.Substring(0, COMPANY_MAX_LENGTH - 1);
                    }
                    else
                    {
                        //Continue.
                    }

                    string myNewPhone = this.UpdateOnePhoneTextBox.Text;
                    myNewPhone = myNewPhone + string.Empty;
                    myNewPhone = myNewPhone.Trim();

                    if (myNewPhone.Length > PHONE_MAX_LENGTH)
                    {
                        myNewPhone = myNewPhone.Substring(0, PHONE_MAX_LENGTH - 1);
                    }
                    else
                    {
                        //Continue.
                    }

                    myConnection = new System.Data.OleDb.OleDbConnection(this.GetConnectionString());
                    myConnection.Open();
                    System.Data.OleDb.OleDbCommand myCommand = new System.Data.OleDb.OleDbCommand(COMMAND_FOR_UPDATE, myConnection);
                    myCommand.Parameters.Add("@CompanyName", System.Data.OleDb.OleDbType.VarChar).Value = myNewCompanyName;
                    myCommand.Parameters.Add("@Phone", System.Data.OleDb.OleDbType.VarChar).Value = myNewPhone;
                    myCommand.Parameters.Add("@ShipperID", System.Data.OleDb.OleDbType.Integer).Value = myShipperID;
                    int myReturnValue = myCommand.ExecuteNonQuery();

                    this.UpdateOneStatusLabel.Text = "The row with ShipperID='" + myShipperID.ToString() + "' has been update if it exists, (or if it does not exist then no changes were made), as of " + DateTime.Now.ToString(DATE_FORMAT_STRING) + ".";
                }
                else
                {
                    this.UpdateOneStatusLabel.Text = "The input value='" + this.UpdateOneShipperIDTextbox.Text + "' must be an Int32 in order to proceed, as of " + DateTime.Now.ToString(DATE_FORMAT_STRING) + ".";
                }
            }
            catch (Exception ex)
            {
                this.Response.Write(ex.ToString());
            }
            finally
            {
                if (myConnection == null)
                {
                    //Continue.
                }
                else
                {
                    myConnection.Close();
                }
            }
        }


http://www.NetBrainer.com
0
mkamoski
9/12/2005 5:27:06 PM
Reply: