|
wetrivrrat wrote:
as you suppected the string Amount = dataReader.GetString(0);
Have you tried object o = dataReader.GetString(0) to see if you get a value at all ?
wetrivrrat wrote:
is my problem due to the fact that i'm creating a new field and it can't ref the new field?
Shouldn't be, no. I don't really use datareaders, though, so I can't be sure.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote:
Shouldn't be, no. I don't really use datareaders, though, so I can't be sure.
what methods do you prefer?
I plugged in your code and still get the same error.....
Dim Beautiful As String
Beautiful = "ignorant"
Label1.Text = "The world is full of " & Beautiful & " people."
Why is common sense such an un-common comodity?
|
|
|
|
|
wetrivrrat wrote:
what methods do you prefer?
The project I work on has a program which generates wrapper classes around our stored procedures, which return datasets. It's not a matter of my choice, that's just what I'm used to working with, by default.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Well, if you get any new ideas please let me know, cause this was supposed to be delivered by weeks end...
any thing will be helpful!
thanks for everything though!
Dim Beautiful As String
Beautiful = "ignorant"
Label1.Text = "The world is full of " & Beautiful & " people."
Why is common sense such an un-common comodity?
|
|
|
|
|
what about doing it in ASP.net? or vb, As i'm not restricted to C# onthis!!!
Dim Beautiful As String
Beautiful = "ignorant"
Label1.Text = "The world is full of " & Beautiful & " people."
Why is common sense such an un-common comodity?
|
|
|
|
|
Did you step through and see if there was an object in the data reader at all, and if it was null ?
VB won't help, it's calling the same framework. Surely you can't change your whole project to ASP.NET ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I will admit no I did not step thru, cause well idon't know how...
and yes, I could convert to asp, as that single query is the core of the project, unless i can get it to run and return the value of the 'sum (amount)' then I could write it in any language i wanted, just so much as it runs!!, the prefered method by the client was web based anyhow, I was just working in C# since it was easier to get things started, as i have tried to stay away from the web based stuff.... so, that all said, ":scratch, scratch" if you don't mind explaining how to step thru or helping me connect to sql(server) thru asp your assistance would be GREATELY apreciated.
Dim Beautiful As String
Beautiful = "ignorant"
Label1.Text = "The world is full of " & Beautiful & " people."
Why is common sense such an un-common comodity?
|
|
|
|
|
wetrivrrat wrote:
I will admit no I did not step thru, cause well idon't know how...
Then I'm surprised you got this far. Highlight the line you want to stop on, and hit F9. A black dot will appear next to it. Hit F5, make sure first you're doing a debug build. Then the code will stop execution on this line, and in the bottom left is a window where you can type variable names and see their values. F10 steps through the code.
Converting to ASP.NET is easy if your middle tier is seperate from your GUI code. But it won't solve this problem.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Sorry, never called it stepping thru, just debugging it....self taught(if you want to call it that) and so far (knock on wood) this is the first real problem I've run into, that I couldn't fix by either re-writing or re-evaluating what I've written. sorry to be of a frustration.
I did step-thru or debug it and found that on the 'object o = dataReader.GetString(0);' you had me test, I am getting the following: o <undefined value=""> System.Object
and for the 'string Amount = dataReader.GetString(0);' I am returning a null, but unless i'm not pulling the correct field the data shouldn't be a null, rather a value of 331.000. Unless its not pulling the data from the variables i set with the +location_id+ which if that were the case, it seems that I would have a failure elsewhere....in the query, but it IS pushing the console.writeline values to the query, so.......
Dim Beautiful As String
Beautiful = "ignorant"
Label1.Text = "The world is full of " & Beautiful & " people."
Why is common sense such an un-common comodity?
|
|
|
|
|
Can you select the parameter by name instead of index ? That is dataReader.GetString("Amount") ?
Doesn't look like it. What if you replace this:
"SELECT sum (Amount) From Transaction_table WHERE Location_ID = @machineName and Shift_Number = @ShiftNumber"
with this:
string.Format("SELECT sum(Amount) as TotalAmount from Transaction_table where Location_ID = {0} and Shift_Number = {1}", machine_name, shift_number)
so that you don't have to mess with parameters at all, just pass in the SQL. ( and so your result has a name )
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian,
We had it all backwards.....
I was using the Getint32 class and while that is fine I am only trying to retrieve one result and since I was creating it as a 'virtual' column it wouldn't pull becasue I apparently was trying to read it in the .net framework data type, but it was returning .net data provider data type. SO this basically means that no matter how i queried it it was never going to convert to the correct data type unless i told it to. plus, when we tried to change the ordnal type from numeric (0,1,2,etc) to alpha ("Amount") it would not read since it only reads ordnals as numeric values. intersting huh? and if it ever helps you out, the datareader provides the fastest level of data retrieval from a DBMS if all you are doing is querying it for reading purposes, so if at work you guys never have to update or insert it may be helpfull to use it.....
who knows, maybe this will all help you or someone else out there one day.....
THANKS FOR YOUR HELP
talk to you later.....but hopefully not!
have a nice day!
Oh, by the way here's the code that paid the bills! ::::
Console.WriteLine("Current Shift Value on machine [" + Location_ID + "] is $" + dataReader["Value"].ToString());
Dim Beautiful As String
Beautiful = "ignorant"
Label1.Text = "The world is full of " & Beautiful & " people."
Why is common sense such an un-common comodity?
|
|
|
|
|
Hi Folks,
I'm trying to access a CSV file as an ODBC to import some data into an Oracle Database. I almost have it.
I have the connect string for Microsoft Text Driver. I have sorted out how to access the CSV file as a table. What I can't figure out how to do is get the Microsoft Text Driver to stop recognizing every field as a VARCHAR(255). This takes a horrible amoung of space and causes compatibility problems with the Oracle table I'm using.
The Microsoft Text Driver will recognize a header on a CSV file with the field names, but I can't figure out how to specify data types with the correct syntax.
Help!!!!!
Matthew Evans
Canada
|
|
|
|
|
With ado (not .net) if i have a RecordSet (basicly an in memory table) can i connect to it as if it where a database and run a select statment against it to return a new recordset? And if it posible would you be so kind as to include a code sniplet.
|
|
|
|
|
I have an application using SQL Server database. After a few insert new data from application into database. That database is seem to be stucked. I can query any function from it any more. I must wait for a while, stop and then restart SQL Server, close (if it's opening) and then open Query Analyzer and change the database processing to the database that my application works with in order to make it works again . And i must exactly follow all the steps above to make it works again.
If i try inserting data from Query Analyzer, there's no thing wrong appears. but right after that if i try to delete that database, i will receive a message that i can't delete that database because it's in use (although i closed my app and query analyzer already). I (again) must stop, and restart SQL Server to delete.
What's my problem? The error is caused by my app or my SQL Server?
Please help me. Thanks!
|
|
|
|
|
I'd check for open transactions..that aren't being committed/rolled back etc..
|
|
|
|
|
I am trying to connect to a database on an AS400 via ODBC and getting some issues with the connection string. I have searched and not found anything that will help.
My connection string is
Private Const RSEL_CONNECTION = "Driver={Client Access ODBC Driver (32- bit)};System=XXX; DBQ=LTL400TNT3;Uid=XXX;Pwd=XXX;"
My calling code is
Dim conn As OdbcConnection
conn = New OdbcConnection(RSEL_Connection)
My error
Message "Format of the initialization string does not conform to specification starting at index 0." String
Any help would be much appreciated. Also, i need to do this via ODBC or OLEDB. I know this is slower, but I cannot use the beta managed database connectors available.
Thanks,
Scott
|
|
|
|
|
Hai,
I want to get the last 10 records from a table containing 100 records.What will be the siplest SQL query ,I can use for retreiving last 10 records,without giving any conditions.I am sure somebody can show my way.
Thank you,
Rahul.
|
|
|
|
|
This is the best I can come up with:
SELECT TOP 10 FROM MyTable ORDER BY ClusteredIndexColumns DESC
Remember that the SELECT statement returns a set, and in a set there is no concept of order, so, in order to maintain this artificial order, to get the first 10 rows chance the DESC to ASC
The ClusteredIndexColumns are the columns that make up your clustered index, this is often the primary key.
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
Hai Colin,
Great.That seems to be the best and simplest way.Thank you very much for your valuable information and for the fantastic help.
Thank you,
Rahul
|
|
|
|
|
I want to know who i can access specif rows in dataset to generate values in other rows: for example, if i ve in forst row [A1 , A2 , A3] and in the second row i ve to calculate value like this [ A5, A4-A2 , A5-(A4-A2)]
remark that A2 from pervious row , i means i need to know how to loop on dataset records in reporting services
need solution as soon as possible
|
|
|
|
|
Hi
Does anyone know how you check to see if a table in a database allready exists?
Hehe. Maybe I should give some more information here:
I have a direct connection to a Access Database via a OleDB Connection, and I am programming in C#.
Wilye
|
|
|
|
|
|
i also use this one, but never tested on MS SQL Server (i use Oracle DB) :
select table_name
from user_tables
order by table_name asc;
cheers,
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
DataTable schemaTable = MyoledbConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables_Info,
new object[] {null, null, null, "TABLE"});
//The schema table's third column contains the Table Names.
//Explore this Table and the commands.
Cheers,
Akos
|
|
|
|
|
YES. That worked. Thanks
Wilye
|
|
|
|