Results 1 to 18 of 18

Thread: C#, CGI and databases

  1. #1

    Thread Starter
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    C#, CGI and databases

    hey, im using C# to write to databases, i can do it though a normal exe normal but when i try and do it though a web page cgi and stuff, it just comes up with an error
    System.Data.OleDb.OleDbException: Operation must use an updateable query.

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    it might be that the database is read only and/or the server is not setup to use an access database...


    ..Im assuming you are using an access database..
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3

    Thread Starter
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099
    im using an access database. i can read write and do every thing to it normaly. but when i try to do it though my server it doesnt work? do i have to set the server up to let C# write though the server, coz it can read from it, but it can write?

  4. #4
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    is this server remote...or yours?
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  5. #5

    Thread Starter
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099
    yer its hosted on my own computer and im running wun2k SP2

  6. #6
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    make sure that your web application virtual directory is set up with write permissions.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  7. #7

    Thread Starter
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099
    ypu the persmission are set to read, write and the execute permission are set to scripts and exectuables.

  8. #8
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    hmm..well I am out of ideas and am about to leave work..If I come up with anything tonight, ill let you know.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  9. #9

    Thread Starter
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099
    thanks any way

  10. #10
    joan_fl
    Guest
    What is the error your getting?

  11. #11

    Thread Starter
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099
    Error Type:
    Microsoft JET Database Engine (0x80004005)
    Operation must use an updateable query.
    its not the code, because ive tryed it using VB asp and none of them will work when i try to write it though my webserver?

  12. #12
    joan_fl
    Guest
    Hmm it should be writing some error to the browser..? Does it not display anything?

  13. #13

    Thread Starter
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099
    sorry, it displays that in the browser with some other stuff, but when i run it from a folder normaly theres no problems? could it be something with IIS?

  14. #14
    PowerPoster abhijit's Avatar
    Join Date
    Jun 1999
    Location
    Chit Chat Forum.
    Posts
    3,228
    Send me your code and db I will try to test it over here.

    rgds,
    abhijit

  15. #15

    Thread Starter
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099
    ive sorted it out now it was something to do with the IIS user config, they didn't have the access rights.


    thanks

  16. #16
    Lively Member
    Join Date
    Sep 2002
    Posts
    100
    Hey John,

    Could you perhaps post the code your using to connect to the database? It seems like it might do what i need(to mysql).

    Thanks,
    -toto

  17. #17

    Thread Starter
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099
    i used mdb, and it was compiled to a exe
    Code:
    using System.Data.OleDb;
    class zzz
    {
    public static void Main()
    {
    try
    {
    OleDbConnection s;
    s = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=f:\\c#\\myDB.mdb");
    s.Open();
    OleDbCommand c;
    string t;
    t=System.Environment.GetEnvironmentVariable("QUERY_STRING");
    //t = "aa=john&bb=tindell";
    string [] u;
    char [] v = new char[2];
    v[0] = '=';
    v[1] = '&';
    u = t.Split(v);
    string f1,f2,f3;
    f1 = u[1].Replace('+',' ');
    f2 = u[3].Replace('+',' ');
    f3 = "insert into bbb values('" + f1 + "','" + f2 + "')";
    System.Console.WriteLine("Content-Type:text/html\n");
    System.Console.WriteLine(f3);
    c=new OleDbCommand(f3,s);
    c.ExecuteNonQuery();
    }
    catch(System.Exception e)
    {
    System.Console.WriteLine(e.ToString());
    }
    }
    }

  18. #18
    Member schizo's Avatar
    Join Date
    Sep 2003
    Location
    http://blackskull.cjb.net
    Posts
    42

    Re: C#, CGI and databases

    hey, do you know how to handle a file upload?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width