I have spent the last 2 years writing a bit of code which is working great at home but when I try and run it at work the network policies do not allow it.
It reads and writes to the following IP: "196.30.221.209"
http://196.30.221.209/phpmyadmin
My IT guys at work can’t get it to allow
Any suggestions. (port No. etc)
Im sure you had this question before
At home and other wifi areas its perfect.
With the following code:
Try
Dim PHPDB As String = "196.30.221.209"
Dim con As MySqlConnection = New MySqlConnection("Data Source=" + PHPDB + ";Database=####;User ID=####;Password=####;")
Dim ds As DataSet = New DataSet()
Dim DataAdapter1 As MySqlDataAdapter = New MySqlDataAdapter()
Dim sql As MySqlCommand = New MySqlCommand("SELECT * FROM TEST_DB ", con)
con.Open()
DataAdapter1.SelectCommand = sql
DataAdapter1.Fill(ds, "TEST_DB")
DGV1.DataSource = ds.Tables(0)
con.Close()
Catch
End Try
Thanks a mill Guys
Well I can access it so you will need to talk to your IT guys. There isn't anything we can really tell you unless you be a lot more specific in what you've tried. I'm sure your work have port 80 unblocked...
What do you see when you try and access it at work? What other details do you have? Can you access another phpmyadmin server? Have you tried reinstalling phpmyadmin?
Related
Hi all I'm having trouble with regards to opening my connection on my mysql database on xampp. I'm not quite sure about the issue here. But please do correct me if I'm wrong, is there a problem with my connectionstring script or does Visual Studio 2019 handle it differently now compared to it's previous versions. I've tried removing the "con.Open()" line. but the problem with this is I can't seem to even be able to insert some data into my databse without the "con.Open()" line
here's the code by the way.
Module Module1
Public con As New MySqlConnection
Public cmd As New MySqlCommand
Sub openCon()
con.ConnectionString = "server=localhost; username=admin; password=; database=db_tutorial"
con.Open()
End Sub
End Module
here's an image of the error by the way.
Firstly, as far as I know sharing the username/password should NOT be done as I'm attempting to make a user register/login program. My server is remote, so I connect to it with an IP address. I have been trying for a very long time but I always run into errors.
Even when providing the MySQL Username and password, it fails entirely.
Some stuff I've tried:
Dim connection As New MySqlConnection("datasource=(ip);port=22;username=root;password=(pwd);database=(db)")
Dim connection As New MySqlConnection("datasource=(ip);port=3306;username=root;password=(pwd);database=(db)")
Dim connection As New MySqlConnection("server=(ip);port=22;username=root;password=(pwd);database=(db)")
And then I realised another thing about my server, I require the SSH option when connecting so I tried this. However I still encounter the same errors on opening the MySQLConnection (portFwld.Start & Client.Connect is successful)
Dim ConnectionInfo = New PasswordConnectionInfo("(IP)", "root", "(PWD)")
Dim ConString = New MySqlConnectionStringBuilder
ConnectionInfo.Timeout = TimeSpan.FromSeconds(7)
Dim client = New SshClient(ConnectionInfo)
client.Connect()
Dim portFwld = New ForwardedPortLocal("127.0.0.1", Convert.ToUInt32("3306"), "(IP)", Convert.ToUInt32("22"))
client.AddForwardedPort(portFwld)
portFwld.Start()
ConString.Server = "(IP)"
ConString.Port = "22"
ConString.UserID = "root"
ConString.Password = "(PWD)"
ConString.Database = "(DB)"
Dim Connection = New MySqlConnection(ConString.ToString)
Connection.Open()
The errors I encountered were mostly these:
{"Reading from the stream has failed."}
and:
{"Unable to connect to any of the specified MySQL hosts."}
I literally have no idea why nothing is working whatsoever. I've searched and searched and I cannot find the solution. Also a reminder; I'm pretty sure I don't want the password revealed so blatantly in a string, let alone revealed at all.
Please be considerate as I'm completely new to this and just want to setup a community program just like any other program/site (like accounts here on Stackoverflow).
Thanks in advance.
The issue was that I needed to go to my server's cPanel and go to the allowed IPs area and add %, after that connection was all successful.
I'm trying to create a reminder that notifies users the number of days before a chemical expires. I'm trying to retrieve the data in my database using ForEach loop, but I can't get the syntax right.
For Each chemicalName as DataRow In chemicalinventory.Rows
For some reason, the error: name 'chemicalinventory' not declared keeps popping up.
From what I seen online, that is supposed to be the table name. Am I coding it wrong? Please answer if you know what's the error.
You cannot just directly start querying tables in this manner. You need to select your data from the database table and use it to fill a DataTable. You can then loop through the rows of this DataTable to get what you're after.
There are many ways to do that, but here is a very basic setup - granted, you'd need to specify a connection string in your Web.Config, and modify the SQL query to be relative to your needs.
Dim sqlConnection1 As New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("YOUR_CONNECTION_STRING").ConnectionString)
Dim cmd As New SqlCommand
cmd.CommandType = Data.CommandType.Text
cmd.CommandText = "SELECT * FROM chemicals"
cmd.Connection = sqlConnection1
Dim DataAdapter As New SqlDataAdapter
DataAdapter.SelectCommand = cmd
Dim chemicalInventory As New DataTable()
DataAdapter.Fill(chemicalInventory)
For each row as DataRow in chemicalInventory.rows
Response.write(row.item("column_name"))
Next
I have developed vb.net app with MySQL and I am using crystal reports that are generated using data from XML files.
Using conn As New MySqlConnection(constr)
Try
Dim ds As New DataSet
Dim da As New MySqlDataAdapter
Dim query_invoice_details As String = "SELECT cust_id,cust_name,cust_contact,cust_email,cust_address,IF(cust_type = 1,'Individual','Company') 'Customer Type',cust_comp_name FROM tbl_customers WHERE cust_status = 1;"
conn.Open()
da.SelectCommand = New MySqlCommand(query_invoice_details, conn)
da.Fill(ds)
ds.WriteXml(CurDir() & "/CustomerReportDetails.xml", XmlWriteMode.WriteSchema)
crCustomerReport1.Refresh()
Finally
If conn IsNot Nothing Then conn.Dispose()
End Try
End Using
Everything is working fine development stage but when the project is published, (installer created and installed), it cannot find the CurDir() to load the report from because, when I use DataExpert to design Crystal Reports, I have to physically select the file (which translates to "E:\_netProjects\Invoices\Invoices\bin\Debug\CustomerReportDetails.xml").
Is there any other way to solve this? Any help is highly appreciated.
I have a MySQL Database called "business elements", which has 4 columns in it (ID,Username,Password & Level). I want to check if a specific username's (given by Usernametextbox.text) "Level" is Admin, Manager or User. These are the 3 values that I want all of my users to have(They are all in the column Level). My connectionstring is "server=localhost;user id=root;password=;database=business elements" and my table is users
Basically I want to check the value of a column with a given user.
All of this is in Visual Basic.
Someone please Help..
Here's how to get the level for a particular username. It should a good starting point for lots of other functions. I haven't tested it, but it should be pretty close. (Userlevel should match the data type for "level"in the table.)
Dim conn as MySqlConnection
Dim cmd As MySqlCommand
conn = New MySqlConnection("server=localhost;user id=root;password=;database=business elements;")
conn.Open()
cmd = New MySqlCommand("SELECT level FROM users WHERE Username=#username LIMIT 1", conn)
cmd.Parameters.AddWithValue("#username", Usernametextbox.Text)
userLevel = cmd.ExecuteScalar()