Category: Database

Feb 04 2010

the connection for viewing your linked microsoft excel worksheet was lost. error 3620

Check below steps to avoid above error

Step 1:

Use below connection for Office 2007 Excel files

string connectionString = “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\user.xls;Extended Properties=\”Excel 8.0;HDR=YES;\“”;

user.xls is Excel file Name (Database name)

Use below connection for Office 97-2003  Excel files

string connectionString = “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\user.xls;Extended Properties=Excel 8.0;”;

step2:

Before adding records from asp.net form to excel close the excel file

After adding records then open and view added record.

Example for insert and display records from excel using asp.net

http://www.codeforasp.net/insert-and-display-data-into-excel-using-asp-net.html

Oct 08 2009

Insert data into asp.net using Oracle Provider msdaora.1

In Oracle
I am going to Create a table in Oracle using database name is dbName

Database name is dbName

Create a table name tblSales with three fields

create table TBLSALES
(
SALESCODE NUMBER not null,
ITEMS     CHAR(32) not null,
SALESDATE DATE not null
)

In Visual Studio

I am going to explain the steps to insert the data into oracle using asp.net application.

Step1: Open VS2005 or 2008 -> New -> website -> choose Asp.net Web     site -> Ok

Step2: Open web.config file to write connection string.

<appSettings>
<add key=”ConnectionString” value=”Provider=msdaora.1;Data Source=dbName;User;Password=aaa;Persist Security Info=True;” />
</appSettings>

step3: In Default.aspx page, Drag three textbox,Button and calender control by clicking calender control date, the date will be displayed in txtDate(its id name of TextBox3)

oracle form

oracle form

give textbox1 ID is txtSalescode
textBox2 ID is txtItems
textBox3 Id is txtDate
Button ID is btnSubmitSales
Step4: In Default.aspx.cs write below code.

add namespace using System.Data.OleDb;

Sample Code in Default.aspx.cs

using System.Data.OleDB;

protected void Page_Load(object sender, EventArgs e)
{

}

protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
txtDate.Text = Calendar1.SelectedDate.ToShortDateString();
}

protected void btnSubmitSales_Click(object sender, EventArgs e)
{

OleDbConnection objConn = new OleDbConnection(ConfigurationManager.AppSettings["ConnectionString"]);

string query = “insert into tblSales(Salescode,Items,SalesDate) values(?,?,?)”;

OleDbCommand objCmd = new OleDbCommand(query, objConn);

objCmd.CommandType = CommandType.Text;

objCmd.Parameters.Add(”@SalesCode”, OleDbType.BigInt).Value = long.Parse(txtSalescode.Text);

objCmd.Parameters.Add(”@Items”, OleDbType.VarChar).Value = txtItems.Text;

objCmd.Parameters.Add(”@SalesDate”, OleDbType.Date).Value = txtDate.Text;

objConn.Open();

objCmd.ExecuteNonQuery();

objConn.Close();

}

Alibi3col theme by Themocracy