I am struggling with something that i thought is simple and straight and forward. I have mysql database and a user defined function in it. I have tested the function in command prompt and works fine but when accessing the function using vb.net application there is a syntax error:;
first i have this syntax error: 'CommandType' is ambiguous, imported from the namespaces or types 'System.Data, MySql.Data.MySqlClient.MySqlCommand'. I tried to solve the problem by using syntax below:
Imports System.Configuration Imports System.Data.DataSet Imports MySql.Data.MySqlClient Imports MySql.Data.MySqlClient.MySqlConnection Imports MySql.Data.MySqlClient.MySqlException Imports MySql.Data.MySqlClient.MySqlCommand Imports System Imports System.Collections.Generic Imports System.Text Imports System.Data Imports MySql.Data Public Class Data Dim con = "server= localhost;" _ & "uid=root;" _ & "database=doset_Management_System;" Dim cn As New MySqlConnection(con) Public Function insertlesson(ByVal faciName As String, ByVal faciSname As String, ByVal Cluster As String, ByVal loca As String, ByVal group As String, ByVal start As String, ByVal endtime As String, ByVal weekDay As String, ByVal year As String) As String Dim msg As String cn.Open() Try Dim status As String = "world" Dim myCommand As New MySqlCommand("hello('" & status & "')", cn) myCommand.CommandType = CommandType.StoredProcedure 'There is an error here. commandType underlined Dim rv As MySqlParameter = myCommand.Parameters.Add("rv", MySqlDbType.String) rv.Direction = ParameterDirection.ReturnValue msg = rv.Value myCommand.ExecuteNonQuery() Catch ex As MySqlException cn.Close() MessageBox.Show("Error number '" & ex.Number & "' has occured. Here is the error: '" & ex.Message & "' ", "Error:") Return False End Try cn.Close() Return msg End Function End Class
first i have this syntax error: 'CommandType' is ambiguous, imported from the namespaces or types 'System.Data, MySql.Data.MySqlClient.MySqlCommand'. I tried to solve the problem by using syntax below:
That acturaly remove the syntax problem but still i get the error message: Error number 1064 has occured. Here is the error: You have an error in your sql syntax; check your manual that correspond to you sql sever version for the right syntax to use near 'world')" at line 1 Please help!myCommand.CommandType = System.Data.CommandType.StoredProcedure
Last edited: