Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

hey i'm working on a vb.net project.

everything works fine but for 1 thing.

i connect to my database, try to insert a value and try to get it back later.

this all works except for 1 value.

 

when my value has the chars '][' in it.

 

the value's are all player names and some have '][' for a T.

How can i still put these names in my database and get them back out.

 

i'm currently using:

 

Dim MyCommand As New OleDbCommand("INSERT INTO playerStats (playerName, playerFrags, playerDeaths, playerHeadshots) VALUES ('" & Player & "', '1', '0', '0')", MyConnection)
MyCommand.ExecuteNonQuery()
MyCommand.Dispose()

 

And

 

Dim playerFrags, playerDeaths, playerHeadshots As String
Dim MyCommand As New OleDbCommand("SELECT * FROM playerStats WHERE playerName = '" & Player & "'", MyConnection)
Dim MyReader As OleDbDataReader = MyCommand.ExecuteReader()
While MyReader.Read
  playerFrags = MyReader("playerFrags")
  playerDeaths = MyReader("playerDeaths")
  playerHeadshots = MyReader("playerHeadshots")
End While
MyReader.Close()
MyCommand.Dispose()

 

Greetz

 

PS: i don't want to replace the '][' by a T cause maybe other names have somesort of unvalid chars in it.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...