|
Sure. This is probably how your code using SQL Server looks:
Imports System.Data.SqlClient
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim DatabaseConnection As New SqlConnection("connectionstringgoeshere")
DatabaseConnection.Open()
Dim SQLCommand As New SqlCommand("SELECT * FROM TABLE", DatabaseConnection)
SQLCommand.ExecuteNonQuery()
DatabaseConnection.Close()
End Sub
End Class
Now, after you have downloaded and installed the MySql Connector/Net, open the project's properties, click References, click Add, and add C:\Program Files\MySQL\MySQL Connector Net 5.1.6\Binaries\.NET 2.0\MySql.Data.dll. That's the default directory, it may be somewhere else on your computer. Next, change your code to MySql. I bolded the changes:
Imports MySql.Data.MySqlClient
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim DatabaseConnection As New MySqlConnection("connectionstringgoeshere")
DatabaseConnection.Open()
Dim SQLCommand As New MySqlCommand("SELECT * FROM TABLE", DatabaseConnection)
SQLCommand.ExecuteNonQuery()
DatabaseConnection.Close()
End Sub
End Class
Again referring back to what Christian said earlier, as long as you don't do any SQL Server-specific queries you should pretty much be able to just replace the SQL Server stuff with the MySql stuff. Make sure to update your connection string to be for MySql. (You can also use OleDbConnection if you don't want to use the MySql Connector.)
Hope this helps...
|
|
|
|
|
I am using tableadapters built from the data source so I can't just replace the sql server commands with the mysql commands. I guess I thought I should be able to just change the
connectionstring and provider name in my config file and it would go to the MySql database.
Tom
|
|
|
|
|
Hi
I want to open a jpg file from calling with button and the image load with windows picture or somthing else.
please help. tanx!
|
|
|
|
|
Bitmap.FromFile
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
please more explanation with complete code.
thank U
|
|
|
|
|
I see someone posted it. I recommend you read the article I link to in my sig, buy a book on VB.NET and learn some basics so you have a basis on which to understand answers given to you. If you can't work things out based on being told what method to call, you're probably just cutting and pasting code you're given but don't understand, and that's not how to learn.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
ViewPictureBox.Image = System.Drawing.Bitmap.FromFile("here is your image path")
|
|
|
|
|
Hello All,
I want to check a simple think in the database ie i want to check the particular data is already in the database or not. Particular table contain only one field and that field is only a primary key. i want to check it with my frond end that is visual studio.net 2008
I write the below code for that
rs.Open("select * from CategoryMaster where categoryname = '"&txtcat.Text &"'", con, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic)
If rs.EOF Then
rs.AddNew()
rs.Fields("CategoryName") = txtcat.Text
rs.Update()
txtcat.Text = ""
txtcat.Focus()
Else
MsgBox("This category is Already in database ")
End If
I that code it shown some error in the below line
rs.Fields("CategoryName") = txtcat.Text
The error is Property 'Item' is 'ReadOnly'
Please help me to resolve this
Thanks
|
|
|
|
|
Try: rs.Fields("CategoryName").Value = txtcat.Text .
|
|
|
|
|
Absoulutely. thankyou so much.
|
|
|
|
|
Hi All, I recently developed a shared COM Addin using VB.Net and Outlook 2003. It works great on local machine but when I install it on Terminal server it doesn't work.
My Addin get installed on Windows 2003 Terminal server with the initial Loadbehavior = 2Hex value under the HKEY_LOCAL_MACHINE in registry. It starts working when I change it to 3Hex. But as soon as another user logs in on termail server and starts outlook, the loadbehavior values becomes 2Hex again and my Addin stops working for all users.
Any idea why registry is being changed by multiple user sessions. I will appreciate your response.
Thanks
|
|
|
|
|
Hiii Expert
I m also working on outlook 2003 add ins using vb.net 2005. and i am facing same problem but i solved my problem following these steps (MSDN Article).
http:
May be this helps you.
Thanx
Mitesh Khatri
|
|
|
|
|
Hey Mitresh, Many thanks for your response. My Addin is a Shared Addin not VSTO one, do you think these steps are same for shared addin?
Nas
|
|
|
|
|
Hi, I did follow the article but still same problem. I guess this article addresses VSTO Addins not Shared COM Addins. Just for the test purpose, I created a small shared COM addin for outlook 2003. After installation it worked fine but as soon 2 users started outlook session (on Terminal server), it stoped working and again Registry Loadbehavior value changed to 2 from 3. This thing is driving me crazy. Does anyone guide me where I am wrong?
Thanks
|
|
|
|
|
Hiii
I also develop excel 2007 Shared add ins and when i run multiple instance of excel then my add in not working properly on same machine. i think add ins working on single instance of a application.
Thanx
Mitesh Khatri
|
|
|
|
|
So it memans we cannot run COM Addin on terminal server?
|
|
|
|
|
Hiii
May be we r unable to run COM Addin on terminal server? but not sure.....
If you get any solution of this problem plz send me at mail id.
Thanx
Mitesh
Khatrimitesh@hotmail.com
|
|
|
|
|
|
I am working with access database and vb.net. I like to make two listBox in a form. first for product list and second for suppliers list of those corresponding products. When I click product list item corresponding suppliers of that product should be show in supplier list.Data retrive from products and suppliers table from database. I am a begainer of programming. Please help me to design the code.
modified on Tuesday, June 24, 2008 5:26 AM
|
|
|
|
|
What's your actual problem?
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|
|
I guess I'll get a 1 vote for this, too, but, the other reply is correct. Do you have a problem, or do you just have no idea how to code this ? What have you tried ?
The list box has a selected index changed event, you can use this to populate the second list
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
sir/madam i would like to rotate an image in the form of rectangle by dragging the upper right corner of the rectangle in a panel box.image drawing and dragging events both in different forms in my project.
|
|
|
|
|
OK - well, you can do a rotate transform on a graphics object.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Don't email me directly.
If you draw the bitmap in the paint event, you can set the rotate transform on the graphics object to rotate the bitmap
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I'm trying to set the selected value from a combo box that is populated from my database,
i cant seem to find a way to do that.
I'm using this to populate my combo box:
Private Sub PopulateCountry()
Dim country As New Client
Dim contryList As OdbcDataReader = country.mpopulateCountry()
Dim objCountry As String
If contryList.HasRows Then
contryList.Read()
Do While contryList.Read
objCountry = contryList(0)
cbxCCountry.Items.Add(objCountry)
cbxCountry.Items.Add(objCountry)
Loop
End If
End Sub
And calling this method(PopulateCountry()) in the form load and then using this to set the value upon my button btnAddToDB:
Dim country As String
country = cbxCCountry.SelectedValue
Any suggestion guys?
|
|
|
|