Как вставить данные в базу данных сервера mysql онлайн
мой код
Imports System.Data.SqlClient Imports MySql.Data.MySqlClient Imports System.IO Public Class ADD1 Dim conn As MySqlConnection Private imagename As String 'this code declare variable as Byte Private imagge() As Byte 'this code declare variable as MemoryStream Private memor As New MemoryStream Dim OpenFile As New OpenFileDialog() Private Sub ADD_Load(sender As Object, e As EventArgs) Handles MyBase.Load idtxt.Focus() End Sub Private Sub LinkLabel4_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel4.LinkClicked img.Image = Nothing End Sub Private Sub PictureBox3_Click(sender As Object, e As EventArgs) Handles PictureBox3.Click Try conn.ConnectionString = "server=111.111.xxx.xxx;Port=4xxx; Uid=axxusxxx; pwd=xxx; database=xxxrus" conn.Open() 'this code insert these rows into database Dim cmd As New MySqlCommand cmd.Connection = conn cmd.CommandText = "INSERT INTO UOBexam([ID],[NAME],[MIDDLE],[LAST],[TELL],[FACULTY],[YEAR],[SEMESTER],[COURSE1],[COURSE2],[COURSE3],[COURSE4],[COURSE5],[COURSE6],[COURSE7],[GPA],[NOTE],[REPORT],[IMAGE]) VALUES (@ID,@NAME,@MIDDLE,@LAST,@TELL,@FACULTY,@YEAR,@SEMESTER,@COURSE1,@COURSE2,@COURSE3,@COURSE4,@COURSE5,@COURSE6,@COURSE7,@GPA,@NOTE,@REPORT,@IMAGE)" With cmd .Parameters.AddWithValue("@ID", idtxt.Text) .Parameters.AddWithValue("@NAME", name1.Text) .Parameters.AddWithValue("@MIDDLE", middle.Text) .Parameters.AddWithValue("@LAST", last.Text) .Parameters.AddWithValue("@TELL", tell.Text) .Parameters.AddWithValue("@FACULTY", ComboBox1.Text) .Parameters.AddWithValue("@YEAR", year.Text) .Parameters.AddWithValue("@SEMESTER", semester.Text) .Parameters.AddWithValue("@COURSE1", course1.Text) .Parameters.AddWithValue("@COURSE2", course2.Text) .Parameters.AddWithValue("@COURSE3", course3.Text) .Parameters.AddWithValue("@COURSE4", course4) .Parameters.AddWithValue("@COURSE5", course5.Text) .Parameters.AddWithValue("@COURCE6", course6.Text) .Parameters.AddWithValue("@COURSE7", course7.Text) .Parameters.AddWithValue("@GPA", GPA.Text) .Parameters.AddWithValue("@NOTE", NOTE.Text) .Parameters.AddWithValue("@REPORT", REPORT.Text) End With conn.Close() Catch ex As Exception MsgBox(ex.Message) conn.Close() 'clean End Try End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Try With OpenFile .InitialDirectory = Application.StartupPath .FileName = "" .Title = "Photo:" .Filter = "Image files: (*.jpg)|*.jpg|(*.jpeg)|*.jpeg|(*.png)|*.png|(*.Gif)|*.Gif|(*.bmp)|*.bmp| All Files (*.*)|*.*" If .ShowDialog = Windows.Forms.DialogResult.OK Then img.Image = System.Drawing.Image.FromFile(.FileName) Else 'Wala lang po.. End If End With Catch ex As Exception MsgBox(ex.Message(), MsgBoxStyle.Critical, "Error...") End Try End Sub Private Sub LinkLabel1_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked End Sub End Class
Что я уже пробовал:
соединение в порядке, но проблема в том, что я не могу вставить данные
$*Developer - Vaibhav*$
телеканал CNN.Открыть();
cmd = new SqlCommand(sql, cnn);
УМК.Метод executenonquery();
УМК.Располагать();
телеканал CNN.Рядом();