1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. GTA Network forum is now in archive mode.

MySQL Connector

Discussion in 'Libraries/Wrappers/Web' started by Gomitung, Sep 29, 2016.

  1. Kempl

    Kempl Member

    Messages:
    19
    Likes Received:
    1
    Joined:
    Nov 22, 2016
    Hey guys, i always got the error in this line:
    Code:
    API.exported.database.executeQuery
    no definition for database
    I tried the name of my database, i tried database etc. sry :=o i dont know what i should do.
    In the meta i included the ressource Oo
     
  2. Kruzzel

    Kruzzel Active Member

    Messages:
    61
    Likes Received:
    2
    Joined:
    Dec 12, 2016
  3. Gun22

    Gun22 Member

    Messages:
    41
    Likes Received:
    3
    Joined:
    Dec 22, 2016
    I try to get working the example execute script, but it always says:
    Code:
    DATABASE: [ERROR] System.InvalidOperationException: Connection must be valid and open.
     
  4. Hunfiu12

    Hunfiu12 New Member

    Messages:
    4
    Likes Received:
    4
    Joined:
    Oct 25, 2016
    Try open the database.cs file and place conn.Open(); after all MySqlCommand cmd = new MySqlCommand(sql, conn);
     
  5. Gomitung

    Gomitung Member

    Messages:
    44
    Likes Received:
    36
    Joined:
    Aug 2, 2016
    Dont do that, if I remember correctly, that removes the pooling features. And will cause lag in long term. I will answer this once I have time
     
  6. wshbR.

    wshbR. Member

    Messages:
    21
    Likes Received:
    0
    Joined:
    Dec 23, 2016
    Anyone knows how to fix this errors?

    Code:
    using System;
    using System.Data;
    using GTANetworkServer;
    using GTANetworkShared;
    using System.Threading;
    using System.Collections.Generic;
    
    public class DatabaseTest : Script
    {
        public DatabaseTest()
        {
            API.onResourceStart += onResourceStart;
        }
    
        public void onResourceStart()
        {
            while (!API.exported.database.isReady())
            {
                Thread.Sleep(500);
            }
            API.exported.database.executeQuery("INSERT INTO users(name,password) VALUES('testing3','Amazing')");
        }
    }
    [​IMG]
     
    Last edited: Dec 26, 2016
  7. Appi

    Appi Active Member Donator Public Relations

    Messages:
    54
    Likes Received:
    3
    Joined:
    Dec 24, 2016
    [11:30:32] EXCEPTION IN RESOURCE rp INSIDE SCRIPTENGINE GlobalLoad
    [11:30:32] Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: "System.Dynamic.ExpandoObject" не содержит определения для "isReady"
    в CallSite.Target(Closure , CallSite , Object )
    в System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
    в RPGResource.GlobalLoad.OnResourceStartHandler()
    в GTANetworkServer.ScriptingEngine.<InvokeResourceStart>b__28_0()
    в GTANetworkServer.ScriptingEngine.MainThreadLoop()
    [11:30:32] Resource doormanager started!
    [11:30:32] Started! Waiting for connections.
    [11:30:32] DATABASE: [INFO] Connected to MySQL

    Whats the truble?
     
    Last edited: Dec 27, 2016
  8. Appi

    Appi Active Member Donator Public Relations

    Messages:
    54
    Likes Received:
    3
    Joined:
    Dec 24, 2016
    database replace to required name in settings.xml
     
  9. GroX0r

    GroX0r Member

    Messages:
    38
    Likes Received:
    7
    Joined:
    Dec 23, 2016
    Hello, thanks.
    I have a problem, the console show me a message with text: "Connection must be valid and open".
    Also isReady is deprecated, i remove the "while". My code is of image.
    Sorry, my english is bad. Thanks :=)

    [​IMG]

    Edit: Ready and working...

    I add conn.Open(); after of all MySqlCommand cmd = new MySqlCommand(sql, conn);
     
    Last edited: Dec 28, 2016
    Rees and TouchMyRAM like this.
  10. Raklatif

    Raklatif Member

    Messages:
    5
    Likes Received:
    1
    Joined:
    Dec 26, 2016
    I'm getting an error that System.Data doesnt exist, any help?
     
  11. SeriousInk

    SeriousInk Member

    Messages:
    22
    Likes Received:
    1
    Joined:
    Oct 19, 2016
    Put "<assembly ref="System.Data.dll" />" in the meta of our resource


    Hello everybody..

    I see that here is nearly no support but i hope for one :=D

    I tried to setup this resource and made a easy "Input Syntax" but the server couldnt find the "database" class :=o
    He has connected to the database but there comes this error:

    Code:
    [21:35:21] Starting...
    [21:35:21] Loading resources...
    [21:35:21] Starting mysql
    [21:35:21] Resource mysql started!
    [21:35:21] Starting gtaocharacter
    [21:35:22] DATABASE: [INFO] Attempting connecting to MySQL
    [21:35:22] Resource gtaocharacter started!
    [21:35:22] Starting roleplay
    [21:35:22] DATABASE: [INFO] Connected to MySQL
    [21:35:22] Resource roleplay started!
    [21:35:22] Started! Waiting for connections.
    [21:35:22] EXCEPTION IN RESOURCE roleplay INSIDE SCRIPTENGINE roleplay
    [21:35:22] Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: System.Dynamic
    .ExpandoObject enthält keine Definition für database.
       bei CallSite.Target(Closure , CallSite , Object )
       bei System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site,
    T0 arg0)
       bei roleplay.onResourceStart()
       bei GTANetworkServer.ScriptingEngine.<InvokeResourceStart>b__28_0()
       bei GTANetworkServer.ScriptingEngine.MainThreadLoop()

    Code:
    public roleplay() {
            API.onPlayerConnected+=OnPlayerConnected;
            API.onResourceStart += onResourceStart;
        }
       
        [Command("Clothes")]
    
        public void onResourceStart()
        {
            API.exported.database.executeQuery("INSERT INTO player (Name,Passwort) VALUES('Stefan','asdfv')"); // If an error happens it throws an exception
        }
    I hope someone can help me :=)

    Thank you
     
    Raklatif likes this.
  12. Juan Adamuz

    Juan Adamuz New Member

    Messages:
    1
    Likes Received:
    0
    Joined:
    Dec 28, 2016
    Tables are created automaticly?
     
  13. Raklatif

    Raklatif Member

    Messages:
    5
    Likes Received:
    1
    Joined:
    Dec 26, 2016
    no
     
  14. Pun1sh3r

    Pun1sh3r Member

    Messages:
    17
    Likes Received:
    4
    Joined:
    Dec 26, 2016
    It's funny to see scripts or Tut's here which are not even working but someone puts it on Wiki even when it doesnt work and that should help New Scripters?

    Anyway, back to topic:

    Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: System.Dynamic.ExpandoObject have no definiton for database.
    bei CallSite.Target(Closure , CallSite , Object )
    bei System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
    bei Login_Register.LRSystem.onResourceStart()
    bei GTANetworkServer.ScriptingEngine.<InvokeResourceStart>b__28_0()
    bei GTANetworkServer.ScriptingEngine.MainThreadLoop()

    Anyone know how to fix it? Mysql is connected to Server and sample script of first Post is used.
     
    SeriousInk likes this.
  15. GroX0r

    GroX0r Member

    Messages:
    38
    Likes Received:
    7
    Joined:
    Dec 23, 2016
    You need to rename the folder to database.
     
  16. SeriousInk

    SeriousInk Member

    Messages:
    22
    Likes Received:
    1
    Joined:
    Oct 19, 2016
    Thanks @GroX0r that fixed this problem..
    But now i tried to read out the Passwort from my player table and this error comes:
    Code:
    [12:50:40] Error (CS0012) at 26: Der Typ 'System.Xml.Serialization.IXmlSerializa
    ble' ist in einer nicht referenzierten Assembly definiert. Fügen Sie einen Verwe
    is auf die Assembly 'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToke
    n=b77a5c561934e089' hinzu.
    [12:50:40] ERROR STARTING RESOURCE roleplay
    [12:50:40] System.ArgumentNullException: Der Wert darf nicht NULL sein.
    Parametername: source
       bei System.Linq.Enumerable.Select[TSource,TResult](IEnumerable`1 source, Func
    `2 selector)
       bei GTANetworkServer.GameServer.StartResource(String resourceName, String fat
    her)
    [12:50:40] Started! Waiting for connections.
    Line 26 is the exported function :=o

    Code:
    public void onResourceStart()
        {
            string sql = "SELECT Passwort FROM player WHERE Name=@name";
            Dictionary<string, string> parameters = new Dictionary<string, string>();
            parameters.Add("@name", "Ink");
            DataTable result = API.exported.database.executePreparedQueryWithResult(sql, parameters);
            string value = result.Rows[0][0].ToString();
            API.consoleOutput(value); //Displays: It works!
        }
    
    Why cant mysql runs easy? :/

    And i changed this line:
    Code:
    Dictionary parameters = new Dictionary();
    to
    Code:
    Dictionary<string, string> parameters = new Dictionary<string, string>();
    Than it shows me this error with the old code:
    Code:
    Fehler    1    Die Verwendung von Typ "System.Collections.Generic.Dictionary<TKey,TValue>" (generisch) macht das 2-Typargument erforderlich.    C:\Users\Stefan\Documents\Coding\VMP\resources\roleplay\roleplay\roleplay.cs    24    9    roleplay
    
    Why does it run at other peoples and why must i change anything?

    Hope for help
     
    Last edited: Dec 29, 2016
  17. wshbR.

    wshbR. Member

    Messages:
    21
    Likes Received:
    0
    Joined:
    Dec 23, 2016
    I dont know what folder you mean, can you explain that more precisely pls?
     
  18. TakeiT

    TakeiT Member

    Messages:
    40
    Likes Received:
    15
    Joined:
    Dec 28, 2016
    Add <assembly ref="System.XML.dll"/> to your meta.xml
     
  19. GroX0r

    GroX0r Member

    Messages:
    38
    Likes Received:
    7
    Joined:
    Dec 23, 2016
    The folder into of resources
     
  20. wshbR.

    wshbR. Member

    Messages:
    21
    Likes Received:
    0
    Joined:
    Dec 23, 2016
    Renaming the folder is not fixing this problem for me.
     

Share This Page