Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > .NET Languages
You last visited: Today at 21:25

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[VB.Net]SQL-Befehle[Question]

Discussion on [VB.Net]SQL-Befehle[Question] within the .NET Languages forum part of the Coders Den category.

Reply
 
Old   #1
 
Baratoik's Avatar
 
elite*gold: 0
Join Date: May 2010
Posts: 167
Received Thanks: 88
[VB.Net]SQL-Befehle[Question]

hallo wie kann ich mit hilfe von diesem Code z.b. das guthaben in einem Label anzeigen


PHP Code:
   
        MySqlConnection 
= New MySqlConnection
       
        MySqlConnection
.ConnectionString "server=localhost;port=3306; user ID=root; password=123456; database=test"
        
MySqlConnection.Open()

        
Dim Myadapter As New MySqlDataAdapter
        
        Dim sqlquary 
"SELECT Guthaben FROM user WHERE Benutzername = '" lbName.Text "';"
        
Dim command As New MySqlCommand
        command
.Connection MySqlConnection
        command
.CommandText sqlquary
        Myadapter
.SelectCommand command

        mydata 
command.ExecuteReader 
Baratoik is offline  
Old 11/16/2011, 09:34   #2
 
elite*gold: 0
Join Date: Jan 2011
Posts: 144
Received Thanks: 73
Hey,
deine Daten müstest du in Etwa so in ein label bekommen:
Code:
do while (mydata.Read)
label.text += mydata(0)
loop
So in etwa müste das gehen, hab es jetzt nicht getestet, ist nur grad aus dem kopf geschrieben.

Gruß Ronox
Ronox is offline  
Old 11/16/2011, 16:51   #3
 
elite*gold: 0
Join Date: Nov 2007
Posts: 62
Received Thanks: 17
Give it a try!
Still in C# but easy to convert to VB.NET

PS. Not sure if it works! I have no MySQL Server on my Home PC

Code:
internal static void Main(string[] args)
{
    using (var connection = new MySqlConnection()
    {
        ConnectionString = "server=localhost; port=3306; user ID=root; password=123456; database=test"
    })
    {
        connection.Open();

        var query = "SELECT Guthaben FROM user WHERE Benutzername = 'Dieter';";

        using (var command = new MySqlCommand()
        {
            Connection = connection,
            CommandText = query
        })

        using (var adapter = new MySqlDataAdapter()
        {
            SelectCommand = command
        })
        {
            var reader = command.ExecuteReader();

            while (reader.Read())
            {
                string output = reader.GetValue(0).ToString();

                Console.WriteLine(output);
            }

            reader.Close();
        }

        connection.Close();
    }
}
Demon-777 is offline  
Old 11/16/2011, 22:05   #4
 
elite*gold: 3
Join Date: Dec 2009
Posts: 969
Received Thanks: 314
In VB.Net Übersetzt
->
Code:
Friend Shared Sub Main(args As String())
	Using connection = New MySqlConnection() With { _
		Key .ConnectionString = "server=localhost; port=3306; user ID=root; password=123456; database=test" _
	}
		connection.Open()

		Dim query = "SELECT Guthaben FROM user WHERE Benutzername = 'Dieter';"

		Using command = New MySqlCommand() With { _
			Key .Connection = connection, _
			Key .CommandText = query _
		}

			Using adapter = New MySqlDataAdapter() With { _
				Key .SelectCommand = command _
			}
				Dim reader = command.ExecuteReader()

				While reader.Read()
					Dim output As String = reader.GetValue(0).ToString()

					Console.WriteLine(output)
				End While

				reader.Close()
			End Using
		End Using

		connection.Close()
	End Using
End Sub
.exTremez™ is offline  
Old 11/17/2011, 21:03   #5
 
elite*gold: 4
Join Date: Mar 2010
Posts: 3,148
Received Thanks: 1,535
Quote:
Originally Posted by Baratoik View Post
hallo wie kann ich mit hilfe von diesem Code z.b. das guthaben in einem Label anzeigen


PHP Code:
   
        MySqlConnection 
= New MySqlConnection
       
        MySqlConnection
.ConnectionString "server=localhost;port=3306; user ID=root; password=123456; database=test"
        
MySqlConnection.Open()

        
Dim Myadapter As New MySqlDataAdapter
        
        Dim sqlquary 
"SELECT Guthaben FROM user WHERE Benutzername = '" lbName.Text "';"
        
Dim command As New MySqlCommand
        command
.Connection MySqlConnection
        command
.CommandText sqlquary
        Myadapter
.SelectCommand command

        mydata 
command.ExecuteReader 
label1.text = mydata ?
Jopsi332 is offline  
Reply


Similar Threads Similar Threads
Gm Befehle ect.
08/21/2011 - Last Chaos - 20 Replies
Hier die gm Befehle: /whoami | GM Modus anschalten. /echo | Nachricht auf dem ganzen Server verkünden. /itemdrop | Lässt das einen das gewünschte Item droppen. /levelup | Bringt dich aufs gewünschte Level. /summon | Ruft einen oder mehrere NPC's/Monster. /statpoint | Setzt die gewünschten Statuspunkte. /skillpoint | Du bekommst sofort X...
GM Befehle
02/13/2010 - Metin2 Private Server - 10 Replies
Hey Wie bekomme ich denn per GM Befehl einen Gaul? habe bereits hier geschaut: Metin2 Chatbefehle Mfg
ini befehle
12/05/2009 - AutoIt - 9 Replies
hi leute ich will wenn ich ein programm habe wo ma was eingeben kann in den befehl GUICtrlCreateInput wie man das speichern kann also das mann wenn man den bot nochmal startet das man nicht alles neu eingeben muss in der help steht der befehl IniWrite("C:\Temp\myfile.ini", "section2", "key", "this is a new value") und $var = IniRead("C:\Temp\myfile.ini", "section2", "key", "NotFound") MsgBox(4096, "Result", $var) aber das kapier ich nicht wo man das hinschreiben muss und so also wenn ich...
[TUT]GM Befehle
12/05/2009 - Metin2 Guides & Templates - 7 Replies
Hallo Leute ;D Alles Fitt? Na ja bei mir ist alles Top. Ich möchte euch mal einen Tut erstelllen über: Befehle Wie ich gesehen habe haben viele Kollgen Probleme mit den Befehlen darum habe ich mich an den Pc gesetzt und die Befehle mal aufgelistet ;)
Chinesiche GM Befehle + Italian Befehle...kann nix mit anfangen vllt kriegt ihrs hin.
05/18/2009 - Metin2 Private Server - 11 Replies
Blub kann damit nix anfangen villeicht wisst ihrs wenn ihr was raus habt wäre es nett wen ihrs mir per pn oder hier im Thread posten würdet bitte keine lügen oder scheiße labern sowas kann ich auf den Tod nicht ausstehen. hauter rein Thx könnt ihr geben wenns euch geholfen hat unso...naja viel spass. Finalmente commandi GM !! Metin2 --- GM COMMAND --- 測試的時候請& #20351;用香港龍駒 8204;試伺服器. 登入測試伺服& #22120;流程如下: 1.安裝香港龍駒 ;主程式



All times are GMT +2. The time now is 21:25.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.