11. ļ word // ļ System.Object Nothing = ����� ��� �� ����� ���
System.Reflection.Missing.Value; Directory.CreateDirectory("c:/CNSI");
// ļ Ŀ¼ string name = "CNSI_" + DateTime.Now.ToLongDateString() + ����� �����
".doc"; object filename = "c://CNSI//" + name; // ļ ·� ����� ��
// Word ĵ Microsoft.Office.Interop.Word.Application WordApp = new ���� � �
Microsoft.Office.Interop.Word.ApplicationClass();
Microsoft.Office.Interop.Word.Document WordDoc = WordApp.Documents.Add(ref
Nothing, ref Nothing, ref Nothing, ref Nothing); IQueryFilter pQueryFilter;
pQueryFilter = pFeatureWorkspace;
ĵ string name = "y00"; object filename = "c://CNSI//" + ����� ���
name;// ļ · object Nothing = System.Reflection.Missing.Value; ����� � ����
//Microsoft.Office.Interop.Word.Application WordApp = new
Microsoft.Office.Interop.Word.ApplicationClass();
Microsoft.Office.Interop.Word.Document WordDocs = WordApp.Documents.Add(ref
Nothing, ref Nothing, ref Nothing, ref Nothing); WordDocs.Close(ref Nothing, ref
Nothing, ref Nothing); WordApp.Quit(ref Nothing, ref Nothing, ref Nothing);
WordDocs.SaveAs(ref filename, ref Nothing, ref Nothing, ref Nothing, ref
Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref
Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
//WordApp.Quit(ref Nothing, ref Nothing, ref Nothing); message = name +
" ĵ ɳɹ� ��� ����Ա��浽 C:CNSI "; hy catch { message = " ļ�� � ������쳣��"; } string path =
"E:\\yxl\\tianjia\\database2.mdb"; IWorkspace iW =
AccessWorkspaceFromPropertySet(path); IFeatureWorkspace pFeatureWorkspace =
(IFeatureWorkspace)iW; ITable pTable = pFeatureWorkspace.OpenTable("database2");
12. C# Access���� ��ݿ�ķ���
//ȡ public OleDbConnection getConn() { ConnectDatabase connstr=new �����
ConnectDatabase(); string connStr=connstr.GetConnectionString(); OleDbConnection
oledb=new OleDbConnection(connStr); return oledb; }
1 OleDbCommand,OleDbDataReader�� ������ ������ݿ�
1. ѯ��
public User getUserFromName(string Searchname) { User tempUser=new User(); try {
OleDbConnection oleconn=getConn();//��ݿ ���� string strSel="select * from MyUser
where UserName='"+Searchname+"'";// ѯ OleDbCommand myCommand=new �� ���
OleDbCommand(strSel,oleconn);// ѯ oleconn.Open();//�� ���� ����ݿ ����
OleDbDataReader reader; reader=myCommand.ExecuteReader();//ִ�в ѯ ꣺꣺꣺꣺� ������ ؼ�¼ ��
if(reader.Read()) { tempUser.ID=(int)reader["UserID"];
tempUser.Name=reader["UserName"].ToString();
tempUser.Salary=(float)reader["UserSalary"];
tempUser.Password=reader["UserPassword"].ToString();
tempUser.Memo=reader["UserMemo"].ToString();
tempUser.Birthday=(DateTime)reader["UserBirthday"];
tempUser.Address=reader["UserAddress"].ToString(); } else
{ throw new Exception("û м ¼"); } reader.Close();//� � �ر ¼ oleconn.Close();//ռ� �� �
ر����
} catch(Exception e) { throw new Exception("����ݿ���"+e.Message); } return
tempUser; }
2. ¼�����
public void InsertUser(User insertuser) { try { OleDbConnection
oleconn=getConn();//��ݿ ���� oleconn.Open();//����ݿ ���� string strSel="insert
into [MyUser]([UserName],[UserPassword],
评论0