Public Function GetDataTableSP(ByVal val1 As String, ByVal val2 As String, ByVal val3 As String) As DataTable
Dim dtdatatable As New DataTable
Dim dtConnection As New OdbcConnection(ConfigurationManager.ConnectionStrings("DBConnection").ToString)
dtConnection.Open()
Dim dtcom As New OdbcCommand("SP_Login", dtConnection)
dtcom.CommandType = CommandType.StoredProcedure
dtcom.Parameters.AddWithValue("_action", val1)
dtcom.Parameters.AddWithValue("_uname", val2)
dtcom.Parameters.AddWithValue("_upassword", val3)
Dim da As New OdbcDataAdapter(dtcom)
da.Fill(dtdatatable)
da.Dispose()
dtConnection.Close()
Return dtdatatable
End Function
this is my code behing code -
this is my code behing code -
Dim dtUsers1 As New DataTable
dtUsers1 = DBClass.GetDataTableSP("Select", txtUserName.Text.Trim(), txtPassword.Text.Trim())
this is my stored procedure in mysql -
this is my stored procedure in mysql -
CREATE DEFINER=`root`@`localhost` PROCEDURE `SP_Login`(_action varchar(10),
_uname varchar(100),
_upassword varchar(30))
BEGIN
if _action = 'Select' then
/*select * from Regis where UName = _uname and pwd = _upassword;*/
select * from Regis where UName = _uname and pwd = _upassword;
end if;
END
when i am running my application , i am getting error like -
ERROR [42000] [MySQL][ODBC 5.1 Driver][mysqld-5.6.10]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SP_Login' at line 1
I am not able to resolve this error.
Please help me.
when i am running my application , i am getting error like -
ERROR [42000] [MySQL][ODBC 5.1 Driver][mysqld-5.6.10]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SP_Login' at line 1
I am not able to resolve this error.
Please help me.
Bogdan IonecuPosted Jul 16, 2013, 6:08 AM
rachayita jaiswalPosted Jul 12, 2013, 12:55 AM
rachayita jaiswalPosted Jul 11, 2013, 11:24 PM
Public Function GetDataTableSP(ByVal val1 As String, ByVal val2 As String, ByVal val3 As String) As DataTable
Dim dtdatatable As New DataTable
Dim conn As OdbcConnection = New OdbcConnection(ConfigurationManager.ConnectionStrings("teststring").ToString)
Dim cmd As OdbcCommand = conn.CreateCommand
cmd.CommandText = "{call SP_Login(_action,_uname,_upassword)}"
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("_action", val1)
cmd.Parameters.AddWithValue("_uname", val2)
cmd.Parameters.AddWithValue("_upassword", val3)
conn.Open()
Dim da As New OdbcDataAdapter(cmd)
da.Fill(dtdatatable)
da.Dispose()
conn.Close()
Return dtdatatable
CREATE DEFINER=`root`@`localhost` PROCEDURE `SP_Login`(_action varchar(10),
_uname varchar(100),
_upassword varchar(30))
BEGIN
if _action = 'Select' then
/*select * from Regis where UName = _uname and pwd = _upassword;*/
select * from Regis where UName = _uname and pwd = _upassword;
end if;
END
Now i am getting error like -
in this line -- da.Fill(dtdatatable)
ERROR [42S22] [MySQL][ODBC 5.1 Driver][mysqld-5.6.10]Unknown column '_action' in 'field list'
i have added screen shot
please check this
Sunny SharmaPosted Jul 11, 2013, 8:10 AM
Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=myDataBase;
User=myUsername;Password=myPassword;Option=3;
Sunny SharmaPosted Jul 11, 2013, 7:07 AM
Your code is working just fine, no errors.
Are you getting this error while creating the stored procedure or while executing your code?