Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
M

Ming Luo

@Ming Luo
About
Posts
87
Topics
59
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • programmatically write changes back to Access 2007 using C#
    M Ming Luo

    Dear all: I am trying to use C# to communicate a small database build in Access 2007. I can read from the database and I can modify the values and save the changes back to database using the DataGridView. However, I am not sure how to modify the values programmatically. Here is the code building the connection.

    string g_ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\TestDB.accdb";

    DataSet g_ds= new DataSet();
    OleDbConnection g_con = new OleDbConnection(g_ConnectionString);
    OleDbDataAdapter g_adapter = new OleDbDataAdapter("Select * from qrySuggestion", g_con);
    g_adapter.Fill(g_ds, "qrySuggestion");

    this.dataGridView1.DataSource = g_ds.Tables[0];
    g_con.Close();

    I have a button on the form and when the button is clicked, save the changes back to the database. The code is as follows:

       public void SaveTable(string tblName, DataTable tbl)
        {
            g\_adapter = new OleDbDataAdapter("select \* from " + tblName, g\_con);
    
            OleDbCommandBuilder bu = new OleDbCommandBuilder(g\_adapter);
            
            g\_adapter.UpdateCommand = bu.GetUpdateCommand();
            g\_adapter.Update(tbl);
            
            tbl.AcceptChanges();
    
            g\_con.Close();
        }
    

    I can use the above code to read from the database and display the data in the DataGridView with no problem. And I can make modification in the DataGridView and save it back by calling the SaveTable method. However, the problem is that I want to make modification programmatically and reflect the changes back to the database. What I did was to add two statement at the beginning of the SaveTable method as:

    DataRow row = tbl.Rows[0];
    row[0] = 30;

    assuming the column 0 i.e. row[0] is a int field. When I add those two statement at the beginning of the SaveTable method. An exception will occur at g_adapter.Update(tbl); the exception is something like:

    Missing DataColumn"pk_ID" in SourceColumn "pk_ID" in DataTable "tblSuggestionBase"

    Can anyone help me out with the problem please? Thanks

    Asura

    Database help csharp database tutorial question

  • Multidelegate with a returned value
    M Ming Luo

    Dear All: I am a bit confused about the delegate with a returned value. For example, I have a delegate as:

    public delegate int Adelegate(MyClass instance)

    Like this, what happens to the returned value if I use multi delegate please? Further, if the delegate returns a bool, how can I declare a delegate that output a bool value please? Should I declare it in the parameters or the return value? Thanks

    Asura

    C# question tutorial

  • Missing .NET configuration tool in win7
    M Ming Luo

    Dear All: I installed VS 2008.NET in my computer which is Win7 System. I tried to find the .NET configuration tool snap-in but I couldn't find either the mscorcfg.msc or the administrative tool from the start menu and control panel. I read the article on the MSDN website but none of the method mentioned there solves the problem. Most importantly, it seems that the file mscorcfg.msc is not installed on my computer. Besides, I tried to install the framework SDK 2.0 but it doesn't solve the problem Could anyone point me how to find the configuration tool please? Thanks

    Asura

    .NET (Core and Framework) csharp visual-studio com help tutorial

  • What's the meaning of "|" and "@" in C#?
    M Ming Luo

    Dear All: Could anyone give me some useful articles about introducing the symbol "|" and "@" in C# please? For example, I saw a code something like:

    FileSystemWatcher fsm = new FileSystemWatcher(Environment.GetEnvironmentVariable("USERPROFILE"));

    fsm.NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite;

    Thanks

    Asura

    C# csharp tutorial question workspace

  • Hash function c++
    M Ming Luo

    Dear all: I am trying to use the hash_map in C++ in VS2005.NET. The code is like: #include ... ... hash H; size_t h = H("ca"); I want to generate the hash value for the string. This code works perfectly in Linux but in VS2005 it complains that: 1>d:\project\vs2005\c++\gmesh\gmesh\ml_geodesic_gridpoint_index.cpp(54) : error C2065: 'hash' : undeclared identifier 1>d:\project\vs2005\c++\gmesh\gmesh\ml_geodesic_gridpoint_index.cpp(55) : error C3861: 'H': identifier not found It seems that the compiler can't find the hash definition. Does anyone have idea to solve this problem for me please? Thanks

    Asura

    C / C++ / MFC c++ help csharp linux

  • Visual Studio 2005.NET problem under Vista
    M Ming Luo

    Yes, I did install both SP1 and the update.

    Asura

    Windows API csharp help visual-studio debugging question

  • Visual Studio 2005.NET problem under Vista
    M Ming Luo

    The file is under my Document directory and there is no access right problem under that directory at all. And I have already installed VS2005 SP1. By the way, I also tried to turned off the UAC but no working anyway. Actually, it might work in some cases but I don't know how it can work.

    Asura

    Windows API csharp help visual-studio debugging question

  • Visual Studio 2005.NET problem under Vista
    M Ming Luo

    Hi all: I come across the problem of using VS2005.NET under Vista. Every time I run it, it prompts a user account control and ask for the administrator previlidge even I use the right button to run as administrator. Then the another window pop up saying administrator permission is recommended for running VS2005 SP1. Again, as I said, I am already running it as administrator. Finally, when I compile a class problem, the compiler complains that the "Failed to write the updated manifest to the resource of file "..\debug\mesh_class.dll". Access is denied. " I have read some documents from MSDN, but they just say that all I need to do is run the program as administrator. But I failed. Can anyone help me please? Thanks in advance

    Asura

    Windows API csharp help visual-studio debugging question

  • What's the meaning of ^ in VS2005.NET
    M Ming Luo

    Does it mean handle is just another way of declaring a pointer? Is that right?

    Asura

    C / C++ / MFC csharp question

  • What's the meaning of ^ in VS2005.NET???
    M Ming Luo

    Because I didn't find it.

    Asura

    Managed C++/CLI csharp question

  • What's the meaning of ^ in VS2005.NET???
    M Ming Luo

    Hi all: I am really confused about the meaning of ^ in VS2005. I see many programs declared as something like: String^ xxx; MyClass^ yyy; Can anyone explain it to me please? Thanks very much!!! Asura

    Asura

    Managed C++/CLI csharp question

  • What's the meaning of ^ in VS2005.NET
    M Ming Luo

    Hi all: I am really confused about the meaning of ^ in VS2005. I see many programs declared as something like: String^ xxx; MyClass^ yyy; Can anyone explain it to me please? Thanks very much!!!

    Asura

    C / C++ / MFC csharp question

  • setup CLapack with VS2005.NET
    M Ming Luo

    Hi all: Does anyone ever use clapack with VS2005.NET? It's really pain, I have spent a whole day on it but I still can't make it work. Here is what I have done and the problems, could anyone help me out please? First I copied files "clapack.lib, libF77.lib, libI77.lib, blas.lib" to the "..\Microsoft Visual Studio 8\VC\PlatformSDK\lib" directory, the header files "clapack.h, f2c.h, blaswrapper.h" to the "..\Microsoft Visual Studio 8\VC\PlatformSDK\Include" directory. I copied the sample code from the website of clapack faq 1.9. I added the input libraries to the project by setting the \project\linker\input property. When compile the program, I got the following errors: 1>main.obj : error LNK2019: unresolved external symbol "int __cdecl dgesvd_(char *,char *,long *,long *,double *,long *,double *,double *,long *,double *,long *,double *,long *,long *)" (?dgesvd_@@YAHPAD0PAJ1PAN122121211@Z) referenced in function _main 1>D:\Project\VS2005\clapack_test\CLapack_test\Debug\CLapack_test.exe : fatal error LNK1120: 1 unresolved externals Can anyone help me please??? Thanks very very much!!!

    Asura

    C / C++ / MFC csharp help visual-studio debugging question

  • Random Float number generator
    M Ming Luo

    Hi all: I need a random float number generator, I tried drand48(), but it complains it as the unrecogonised identifier. Is there any other function please? Thanks

    Asura

    C / C++ / MFC question lounge

  • How to pass array to function?
    M Ming Luo

    Hi all: I have the following codes: typedef struct Point3Struct { double x, y, z; } Point3; ... Point3 Object1_vertex[] = {...} ... void someFunction(Point3 *vertex_list){ size_t size = sizeof(vertex_list) / sizeof(Point3); ... } int main(){ someFunction(Object1_vertex); } By passing the vertex array into the function "someFunction", I want to calculate the size of the array and do some other operations. But why this doesn't work? When I trace the program, the varialbe size is always 0. And the vertex_list is just the first element of the array. Other than that, if I try to do something like size_t size = sizeof(Object1_vertex) / sizeof(Point3); It will give me an error message saying that error C2070: 'Point3 []': illegal sizeof operand which complains about the "sizeof(Object1_vertex)". How should I solve the problem please? If I want to pass an array into a function, is this the correct way to do that???

    Asura

    C / C++ / MFC help data-structures debugging tutorial question

  • What's the problem of my program?
    M Ming Luo

    Hi all: The following is my program. #define WIN32_LEAN_AND_MEAN #include #include #include #include #include "lapack\matrix_clapack.h" #define NDIM 2 #define M_PI 3.14 int main (){ integer i, j, info2; integer N, NRHS, LDA, LDB; doublecomplex *A; doublecomplex *B; static integer IPIV[NDIM], INFO; A = (doublecomplex*) malloc(NDIM*NDIM*sizeof(doublecomplex)); B = (doublecomplex*) malloc(NDIM*sizeof(doublecomplex)); N=NDIM; NRHS=1; LDA=NDIM; LDB=NDIM; for (i=0;i And here is the compiler message: `1>------ Build started: Project: test, Configuration: Debug Win32 ------ 1>Compiling... 1>test.cpp 1>Linking... 1>test.obj : error LNK2019: unresolved external symbol _zgesv_ referenced in function _main 1>D:\Project\test\Debug\test.exe : fatal error LNK1120: 1 unresolved externals 1>Build log was saved at "file://d:\Project\test\test\Debug\BuildLog.htm" 1>test - 2 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========` I just want to try to test the LAPACK library. But what's the problem with this program please? Thanks Asura

    C / C++ / MFC help c++ debugging question workspace

  • Is there any matrix library in C++?
    M Ming Luo

    Hi all: Is there any existing matrix library and ODE solver in VS2005.NET? Or if somewhere else? I have got the book "numerical recipes in c++", or should I code the program by myself according to the algorithms introduced in the book? Thanks

    Asura

    C / C++ / MFC csharp c++ question learning

  • What's the meaning of the following code?
    M Ming Luo

    Hi all: I am trying to write data back to the Access Database. The following method seems to work well. But I don't understand what the following piece of code exactly work. public static void WriteToDatabase(string tableName) { System.Data.OleDb.OleDbDataAdapter databaseAdapter = new OleDbDataAdapter("Select * from "+tableName, conn); new OleDbCommandBuilder(databaseAdapter); try { databaseAdapter.Update(ds, tableName); ds.Tables[tableName].AcceptChanges(); MessageBox.Show("Congratulations"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } Could anybody explain it to me please? Or maybe you can give me a better way to write data back to access database please? Thank you very much

    Asura

    C# database question announcement

  • How to make an number only text box?
    M Ming Luo

    Hi all: I am doing a windows form application. I need to some textboxes which can only be inserted numbers like prices. Is there any existing component in windows application of C# please? What's the best way of achieving this please? Thanks alot

    Asura

    C# csharp tutorial question

  • How to track the mouse motion?
    M Ming Luo

    Hi all: I am doing a OpenGL project. I want to create a function tracking the mouse motion so that the object in the window can spin or rotate according the mouse motion. I know there is a void glutMotionFunc(void (*func)(int x, int y)); registration function. Does anybody know how to achieve the functionality please? Thanks in advance!!! Asura

    C / C++ / MFC graphics game-dev tutorial question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups