+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 25

Thread: Problem with MySql Stored Procedure

  1. #1
    Lazy Bum micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky's Avatar
    Join Date
    Jul 2008
    Location
    India
    Posts
    693
    Blog Entries
    1
    Rep Power
    6

    Problem with MySql Stored Procedure

    hey guys
    I am having some problems with trying to get results from MySql sp in .net.
    My sp
    Code:
    CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_LoginCheck`()
    BEGIN
      Select First_Name, Last_Name From tblUserMaster Where Email_Id='xxx';
    END
    
    My Code
    Code:
    Dim Cmd As New OdbcCommand("sp_LoginCheck()", Con)
    Cmd.CommandType = CommandType.StoredProcedure
    
    Dim Dtr As OdbcDataReader = Cmd.ExecuteReader()
    Cmd.Dispose()
    
    If Dtr.HasRows Then
        Response.Write("Welcome " & Dtr("First_Name") & " " & Dtr("Last_Name"))
    Else
        Response.Write("No Results")
    End If
    Dtr.Close()
    
    My Error
    Code:
    ERROR [42000] [MySQL][ODBC 3.51 Driver][mysqld-5.0.51b-community-nt]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_LoginCheck()' at line 1
    
    Really have no idea and no experience with MySql and stored procedures.
    Can anyone help me

    @J, Response.Write(Cmd.CommandText.ToString()) also doesnt write the resultant query

    Micky

  2. #2
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Washington, D.C.
    Posts
    2,354
    Blog Entries
    9
    Rep Power
    19

    Last time I worked with MySQL was before they had Stored Procedures.

    Anyway, take a look at how rr did it here: Stored Procedures on MySQL - MySQL
    jmurrayhead
    If you agree, give me rep. If my post helped you, click "Thanks".
    If you like it here...throw us a few bones to help support us.


  3. #3
    Lazy Bum micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky's Avatar
    Join Date
    Jul 2008
    Location
    India
    Posts
    693
    Blog Entries
    1
    Rep Power
    6

    Thanx J, but his problem isnt related to .net(i think).

    No idea what to do
    May be RR can give me more insight

  4. #4
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Washington, D.C.
    Posts
    2,354
    Blog Entries
    9
    Rep Power
    19

    I'm not sure your problem is related to .Net either.

    Try removing the parenthesis here:
    Code:
    Dim Cmd As New OdbcCommand("sp_LoginCheck()", Con)
    
    Code:
    Dim Cmd As New OdbcCommand("sp_LoginCheck", Con)
    
    jmurrayhead
    If you agree, give me rep. If my post helped you, click "Thanks".
    If you like it here...throw us a few bones to help support us.


  5. #5
    Lazy Bum micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky's Avatar
    Join Date
    Jul 2008
    Location
    India
    Posts
    693
    Blog Entries
    1
    Rep Power
    6

    no change J

  6. #6
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Washington, D.C.
    Posts
    2,354
    Blog Entries
    9
    Rep Power
    19

    Alright, try creating your procedure using the syntax that rr did with his.
    jmurrayhead
    If you agree, give me rep. If my post helped you, click "Thanks".
    If you like it here...throw us a few bones to help support us.


  7. #7
    Lazy Bum micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky's Avatar
    Join Date
    Jul 2008
    Location
    India
    Posts
    693
    Blog Entries
    1
    Rep Power
    6

    Quote Originally Posted by jmurrayhead View Post
    Alright, try creating your procedure using the syntax that rr did with his.
    u think my SP is wrong?
    i have MySql Administrator, i made my SP using it and it shows no error there!

  8. #8
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Washington, D.C.
    Posts
    2,354
    Blog Entries
    9
    Rep Power
    19

    Quote Originally Posted by micky View Post
    u think my SP is wrong?
    i have MySql Administrator, i made my SP using it and it shows no error there!
    The reason I feel it's an issue with the SP is that the error returned is a MySQL error...not a .Net error.
    jmurrayhead
    If you agree, give me rep. If my post helped you, click "Thanks".
    If you like it here...throw us a few bones to help support us.


  9. #9
    Lazy Bum micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky's Avatar
    Join Date
    Jul 2008
    Location
    India
    Posts
    693
    Blog Entries
    1
    Rep Power
    6

    ok it works, i chnaged to this
    Code:
    Dim Cmd As New OdbcCommand("call sp_LoginCheck", Con)
    
    Now let me try sending parameters and see, i'll b back with questions

  10. #10
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Washington, D.C.
    Posts
    2,354
    Blog Entries
    9
    Rep Power
    19

    Quote Originally Posted by micky View Post
    ok it works, i chnaged to this
    Code:
    Dim Cmd As New OdbcCommand("call sp_LoginCheck", Con)
    
    Now let me try sending parameters and see, i'll b back with questions
    hmm..interesting...any reason you're using ODBC instead of the MySQL connector? Your syntax before, minus the parenthesis, would have probably worked if you were using that instead.
    jmurrayhead
    If you agree, give me rep. If my post helped you, click "Thanks".
    If you like it here...throw us a few bones to help support us.


+ Reply to Thread
Page 1 of 3 1 2 3 LastLast

Similar Threads

  1. Dynamic Stored Procedure without Building Strings
    By jmurrayhead in forum SQL Code Samples
    Replies: 11
    Last Post: March 17th, 2009, 12:12 PM
  2. Using Parameterized Stored Procedure
    By richyrich in forum MySQL
    Replies: 14
    Last Post: June 12th, 2008, 07:00 AM
  3. Stored Procedures on MySQL
    By richyrich in forum MySQL
    Replies: 7
    Last Post: June 9th, 2008, 11:15 AM
  4. If statement stored procedure
    By peebman2000 in forum SQL Development
    Replies: 32
    Last Post: May 23rd, 2008, 03:54 PM
  5. Dynamic Stored Procedure
    By jmurrayhead in forum Microsoft SQL Server
    Replies: 16
    Last Post: March 26th, 2008, 11:19 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO