Friday, September 3, 2010

how to create ms acess database at runtime for seprate finance year




using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ADOX; (for this u have to add refrence)





private void button1_Click(object sender, EventArgs e)
{
try
{
CatalogClass cat = new CatalogClass();
string tmpStr;
string filename = txtStartingYear.Text + "-" + txtEndingYear.Text;
tmpStr = "Provider=Microsoft.Jet.OLEDB.4.0;";
tmpStr += "Data Source= C:\\" + filename+".mdb" + ";Jet OLEDB:Engine Type=5";
cat.Create(tmpStr);
Table nTable = new Table();
nTable.Name = "PersonData";
nTable.Columns.Append("LastName", DataTypeEnum.adVarWChar, 25);
nTable.Columns.Append("FirstName", DataTypeEnum.adVarWChar, 25);
nTable.Columns.Append("Address 1", DataTypeEnum.adVarWChar, 45);
nTable.Columns.Append("Address 2", DataTypeEnum.adVarWChar, 45);
nTable.Columns.Append("City", DataTypeEnum.adVarWChar, 25);
nTable.Columns.Append("State", DataTypeEnum.adVarWChar, 2);
nTable.Columns.Append("Zip", DataTypeEnum.adVarWChar, 9);
cat.Tables.Append(nTable);
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(nTable);
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(cat.Tables);
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(cat.ActiveConnection);
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(cat);
}
catch (Exception ex)
{
MessageBox.Show("Database with this name already exists");
}
}

ASP.NET Core

 Certainly! Here are 10 advanced .NET Core interview questions covering various topics: 1. **ASP.NET Core Middleware Pipeline**: Explain the...