5 Replies - 203 Views - Last Post: 27 April 2019 - 08:34 AM Rate Topic: -----

#1 CoderSniping   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 27-April 19

How do i populate SQL result from PHP to data table?

Posted 27 April 2019 - 04:43 AM

I'm trying to retrieve data from my server(SQL) through PHP. I used PHP to communicate from my windows app/form to my server. To retrieve data, i used this
data = GetPageAsString("getplayerInfo", "&name=" & My.Settings.Name)
. "Data" will hold my retrieve result from PHP. My sql has 3 data which i want to populate to my Data table but i'm having trouble doing so. I can get 1 Data an populate but when i try to populate more than one, it says Array or when i put .Length it will show 5. I did create my column by doing below. My question now, how do i populate the retrieved data/results from my SQL through PHP into my data table?

-------- CREATING COL ----------
leaveTable.Columns.Add("Application Date", Type.GetType("System.Int32"))
leaveTable.Columns.Add("Comment", Type.GetType("System.String"))
leaveTable.Columns.Add("Status", Type.GetType("System.String"))


My PHP Code to catch the results from my phpmyadmin
$getResult= myDB::get_results("SELECT `player_comment` FROM ' . TABLE_PREFIX . 'player WHERE `playerid`='.$playerid");
       
       return  $getResult->player_comment;


Is This A Good Question/Topic? 0
  • +

Replies To: How do i populate SQL result from PHP to data table?

#2 Sheepings   User is offline

  • Senior Programmer
  • member icon

Reputation: 223
  • View blog
  • Posts: 1,260
  • Joined: 05-December 13

Re: How do i populate SQL result from PHP to data table?

Posted 27 April 2019 - 06:36 AM

Firstly : it says Array or when i put .Length it will show 5 - Explain and provide an example of what you're referring to here as its not in the snipped of code you posted.

Secondly : PhpMyAdmin is not part of SQL server, as you specified you were using - I'm trying to retrieve data from my server(SQL) Which is it? MySQL or SQL?

Thirdly : Why are you doing it the complicated way? If you're using SQL Server, you can connect remotely and bind allowed connections to specific IP's. See Remote SQL or Remote MySQL

Where exactly does php fit in with VB.NET? Clarity needed here... If you install mysql-for-visualstudio-1.2.6, you can connect directly through your VB.NET app, providing the relative MySQL drivers are also referenced in your application. NOTE: Make sure you install 1.2.6 MySQL for Visual Studio connector, otherwise you won't be able to connect to MySQL due to multiple bugs in the latter releases, and remember to give references to MySQL, and MySQL.Client in your .NET app.
Was This Post Helpful? 0
  • +
  • -

#3 CoderSniping   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 27-April 19

Re: How do i populate SQL result from PHP to data table?

Posted 27 April 2019 - 06:44 AM

View PostSheepings, on 27 April 2019 - 06:36 AM, said:

Firstly : it says Array or when i put .Length it will show 5 - Explain and provide an example of what you're referring to here as its not in the snipped of code you posted.

Secondly : PhpMyAdmin is not part of SQL server, as you specified you were using - I'm trying to retrieve data from my server(SQL) Which is it? MySQL or SQL?

Thirdly : Why are you doing it the complicated way? If you're using SQL Server, you can connect remotely and bind allowed connections to specific IP's. See Remote SQL or Remote MySQL

Where exactly does php fit in with VB.NET? Clarity needed here... If you install mysql-for-visualstudio-1.2.6, you can connect directly through your VB.NET app, providing the relative MySQL drivers are also referenced in your application. NOTE: Make sure you install 1.2.6 MySQL for Visual Studio connector, otherwise you won't be able to connect to MySQL due to multiple bugs in the latter releases, and remember to give references to MySQL, and MySQL.Client in your .NET app.


Hi, talking about using SQL server, i am using website hosting and yes im familiar with sql connection. But, after you mentioned about connecting directly, how do connect from my windows form app to my server hosting database?
Was This Post Helpful? 0
  • +
  • -

#4 Sheepings   User is offline

  • Senior Programmer
  • member icon

Reputation: 223
  • View blog
  • Posts: 1,260
  • Joined: 05-December 13

Re: How do i populate SQL result from PHP to data table?

Posted 27 April 2019 - 07:02 AM

There is no need to quote the person above, especially since I am the only one who has replied. Just use the reply area at the bottom.

Now, you seem to be misunderstanding something. SQL Connection is not the same as what ?I am referring to with MySQL for Visual Studio connector. - Just to be clear. And what does php and PhpMyAdmin have to do with this if you are using an SQL server from your provided host?

Quote

My PHP Code to catch the results from my phpmyadmin


I have already given you information on how to connect to a MySQL server remotely through VB.Net. You need to write out your connection strings and your MySQL Commands and pass your queries to those commands for execution.

Since you've mentioned both MySQL and SQL, I am not clear why you mentioned them or which you are using. If you want, you can also setup a SQL connection in VB.NET and some sample example code to help get started.
Was This Post Helpful? 0
  • +
  • -

#5 Sheepings   User is offline

  • Senior Programmer
  • member icon

Reputation: 223
  • View blog
  • Posts: 1,260
  • Joined: 05-December 13

Re: How do i populate SQL result from PHP to data table?

Posted 27 April 2019 - 07:18 AM

I should also point out that the above links can be changed easily, using the same code. Example for MySQL
[code]Dim cs As String = "Database=testdb;Data Source=localhost;" _
            & "User Id=testuser;Password=test623"

        Dim conn As New MySqlConnection(cs)
[/code]Can be changed to the following for SQL
        Dim cs As String = "Database=testdb;Data Source=localhost;" _
            & "User Id=testuser;Password=test623"

        Dim conn As New SqlConnection(cs)
If you want to use SQL, rename anything that starts with My and it will work with SQL server. You will however need to import the SQL namespace/dll files. Hope this helps.
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14994
  • View blog
  • Posts: 59,870
  • Joined: 12-June 08

Re: How do i populate SQL result from PHP to data table?

Posted 27 April 2019 - 08:34 AM

You could make a web service or API to be used. I illustrated this in a tutorial some years ago.

https://www.dreaminc...sumed-by-vbnet/
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1