473,320 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Can't get data from database

I am trying to get the output from a stored procedure. When I enter a value into the stored procedure directly in SQL server management studio it works fine, but when I do it using my code I get nothing. But if I use cmd.parameters("@oOCR").value then I get the first 5 characters, but the last 5 are all zeros. Here is my current code:
Expand|Select|Wrap|Line Numbers
  1. Public Sub GetPlayerCardNumber(ByVal input As String)
  2.         Dim con As SqlConnection = New SqlConnection("Data Source=" & DB1 & ";Initial Catalog=WinOasis;Persist Security Info=True;User ID=" _
  3.                                                      & DBUsername & "; password=" & DBPassword)
  4.         Dim cmd As SqlCommand
  5.         Dim Ireturn As String
  6.         Dim SQLRdr As SqlDataReader
  7.  
  8.         If con.State = ConnectionState.Closed Then con.Open()
  9.         cmd = New SqlCommand("GW_Magtoocr", con)
  10.         cmd.CommandType = CommandType.StoredProcedure
  11.         cmd.Parameters.Add("@iMag", SqlDbType.Char, 18)
  12.         cmd.Parameters("@iMag").Value = input
  13.         cmd.Parameters.Add("@oOCR", SqlDbType.VarChar, 10)
  14.         cmd.Parameters("@oOCR").Value = "4"
  15.         cmd.Parameters("@iMag").Direction = ParameterDirection.Input
  16.         cmd.Parameters("@oOCR").Direction = ParameterDirection.InputOutput
  17.         cmd.ExecuteNonQuery()
  18.  
  19.         SQLRdr = cmd.ExecuteReader
  20.  
  21.         While SQLRdr.Read
  22.             Ireturn = SQLRdr.GetValue(1)
  23.         End While
  24.  
  25.         MsgBox(Ireturn)
  26.         con.Close()
  27.         'SQLRdr.Close()
  28.  
  29.     End Sub
Aug 24 '10 #1
1 1125
debasisdas
8,127 Expert 4TB
Please check this, just might help you.
Aug 26 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Orlando Jin | last post by:
How can I get database SID in stored procedure in Oracle?
0
by: lynn | last post by:
Hello everybody, I am having difficulties: I am working on Mac OSX 10.2.8 with mysql 4. I needed to change the data directory of MySQL from its original place (where the application have to be...
8
by: W.Davis | last post by:
Group, I'm using ver 5 with winXP. I can access the test database, but can't create a table. I can't create ANY database as I keep getting error 1044 (42000): Access denied for user: '...
10
by: MHenry | last post by:
Hi, We were going merrily along for 6 years using this database to record all client checks that came into our office, including information about what the checks were for. Suddenly, network...
4
by: barbara_dave | last post by:
Hi, all We have a database which was running on the server and used by several users. We can not the database now with the following message: The "*.mdb" need to be repaired or isn't a...
1
by: Antanas | last post by:
The following CarsElement XML data type is passed in CTE. Can XML data type be passed as out parameter for SQL stored procedure or returned in SQL UDF. WITH CarsDef(CarsElement) as (SELECT...
1
by: arun_kumar112 | last post by:
HI , I am new member of this comminity, let me introduce first, i am MCA final year student, doing a project on network system, and database . will you tell me how can we connect database (...
1
by: Henry16 | last post by:
Hi. Impossible to create a database using MySQL !!! Message : #1006 - Can't create database 'boby'. (errno: 13) I was told : chown mysql.mysql -R /var/lib/mysql chmod 750 -R /var/lib/mysql...
8
by: Bhuwan Bhaskar | last post by:
Hi, Can we access database (SQL) using AJAX ? Thanks, Bhuwan
6
by: sarah2855 | last post by:
Hello everyone, I'm running a Make-Table Query in Access. They was working fine up intill an hour ago and suddenly now that I'm running the query , I keep getting this error message: Can not...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.