|
I don't know of any off hand, but because most code you write, uses the .NET framework, which is the same, the main things are to get used to using braces and using square brackets for arrays, and semi colons at the end of lines. Apart from the grammar, the languages are basically the same.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
HI,
Im gettin an exception saying "InvalidOperationException" nd it says "No data exists for the row/coloumn", for the following code, nd d exception results on the d line that has been underlined....please check d code nd help....plssss!!!!
int rnd;
int totalcount = 0;
Random SelectRandom = new Random();
OleDbConnection access = new OleDbConnection();
OleDbCommand accesscmd = new OleDbCommand();
OleDbDataReader reader;
if (combo_Category.Text == "Book")
{
string connectionstring = "Provider = Microsoft.Jet.OLEDB.4.0;
Data Source = |DataDirectory|\\HangmanDatabase.mdb";
access.ConnectionString = connectionstring;
access.Open();
accesscmd.CommandText = "Select * From Book";
accesscmd.Connection = access;
reader = accesscmd.ExecuteReader();
while (reader.Read())
{
totalcount = totalcount + 1;
}
if (reader.HasRows)
{
rnd = SelectRandom.Next(0,totalcount - 1);
book = reader[rnd].ToString();
datastring = book.ToCharArray();
}
access.Close();
convert();
}
Pleassssssss help!!!
Ξ:::...£!ΠŤØ...:::Ξ®
|
|
|
|
|
linto_11 wrote: nd d
linto_11 wrote: d code nd help
This txt speak makes you look even more retarded than posting a new question right above your old one does.
linto_11 wrote: book = reader[rnd].ToString();
You need to read some books, and read the documentation. You can't just invent code and expect it to work. What your code does, is reads every row. Then, the reader is pointing to the end of the file. Then your code, in theory, tries to read a column of data on the current row, only, it's no longer pointing to a row. The issue is that you have no idea what you're doing.
The way I would do this, is to read the data into a dataset, then check how many rows the table has, and access a random row from there. That would have the distinct advantage of actually working. The other way would be to store the data into an array as you read it, then access the array at random. That would have the advantage of being something you could do on load, and remove words as you use them, meaning you don't need to access the DB again for that game session.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
linto_11 wrote: book = reader[rnd].ToString();
Are u sure with this?
CG is rite, first read some book.
|
|
|
|
|
im not workin.......im a student....searchin for doubts!!
Ξ:::...£!ΠŤØ...:::Ξ®
|
|
|
|
|
If you want to be a student, start by buying books, not by guessing what code you think will work. Then you will be fine. Buy a book.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Then its really advisable for you to read a book first.
I still didn't understand the logic of posting same question.
|
|
|
|
|
Tks a lot for ur advice....i'll look that i buy a book nd study first..tks!!
Ξ:::...£!ΠŤØ...:::Ξ®
|
|
|
|
|
Can u help me with which books to study????.....i wld b very much thankful!!
Ξ:::...£!ΠŤØ...:::Ξ®
|
|
|
|
|
Buy any book for Beginners in C#.Net.
|
|
|
|
|
linto_11 wrote: Can u help me with which books to study
Well, since you posted this question in the C# forum, I think the first one you need is on C#. If you want to start immediately then .NET Book Zero[^] will get you going.
|
|
|
|
|
At this point, I can't imagine there is a book that WOULDN'T help. Just learning to use google and read the MSDN would be a huge help. Just buy a cheap book on C#, that is for beginners. The 24 hour or the dummies books are a good place to start.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Don't forget one on how to write clearly, without using txtspk!
|
|
|
|
|
I love it when I'm the one who gives the answer, and they won't respond to anything I say.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
HI,
Im gettin an exception saying "InvalidOperationException" nd it says "No data exists for the row/coloumn", for the following code, nd d exception results on the d line that has been underlined....please check d code nd help....plssss!!!!
int rnd;
int totalcount = 0;
Random SelectRandom = new Random();
OleDbConnection access = new OleDbConnection();
OleDbCommand accesscmd = new OleDbCommand();
OleDbDataReader reader;
if (combo_Category.Text == "Book")
{
string connectionstring = "Provider = Microsoft.Jet.OLEDB.4.0;
Data Source = |DataDirectory|\\HangmanDatabase.mdb";
access.ConnectionString = connectionstring;
access.Open();
accesscmd.CommandText = "Select * From Book";
accesscmd.Connection = access;
reader = accesscmd.ExecuteReader();
while (reader.Read())
{
totalcount = totalcount + 1;
}
if (reader.HasRows)
{
rnd = SelectRandom.Next(0,totalcount - 1);
book = reader[0].ToString();
datastring = book.ToCharArray();
}
access.Close();
convert();
}
Pleassssssss help!!!
Ξ:::...£!ΠŤØ...:::Ξ
|
|
|
|
|
You have to put following code:
linto_11 wrote: if (reader.HasRows)
{
rnd = SelectRandom.Next(0,totalcount - 1);
book = reader[0].ToString();
datastring = book.ToCharArray();
}
inside While(reader.Read()) loop.
If u put that code inside while then u don't need if(reader.HasRows) loop.
Also, call reader.Close() before access.Close().
Hope it'll solve ur problem.
|
|
|
|
|
nagendrathecoder wrote:
inside While(reader.Read()) loop.
If u put that code inside while then u don't need if(reader.HasRows) loop.
Also, call reader.Close() before access.Close().
Again it is creating the same issue.....sumthing serious.........please help!!!
Ξ:::...£!ΠŤØ...:::Ξ
|
|
|
|
|
Do you know anything about programming at all ? How did you write this code, if you don't understand what it does ? If you get an exception saying you're trying to read something that's empty, then you need to check first to make sure it has data. That's what the message is telling you. You've changed your code, but not posted the code, or the exact error message. Have you tried to debug this code at all ? It doesn't seem to me like you're trying too hard to get help, or that you're doing anything to try to fix this beyond posting here and hoping we'll fill the gaps of your shortcomings.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Try to do it like this:
int rnd;
int totalcount = 0;
Random SelectRandom = new Random();
OleDbConnection access = new OleDbConnection();
OleDbCommand accesscmd = new OleDbCommand();
OleDbDataReader reader;
if (combo_Category.Text == "Book")
{
string connectionstring = "Provider = Microsoft.Jet.OLEDB.4.0;
Data Source = |DataDirectory|\\HangmanDatabase.mdb";
access.ConnectionString = connectionstring;
access.Open();
accesscmd.CommandText = "Select * From Book";
accesscmd.Connection = access;
reader = accesscmd.ExecuteReader();
while (reader.Read())
{
totalcount = totalcount + 1;
rnd = SelectRandom.Next(0,totalcount - 1);
book = reader.GetValue(0).ToString();
datastring = book.ToCharArray();
}
reader.Close();
access.Close();
convert();
}
I have doubts on following line:
datastring = book.ToCharArray();
R u sure, this line work?
Also, what are you doing if reader is empty?
|
|
|
|
|
nagendrathecoder wrote: totalcount = totalcount + 1;
rnd = SelectRandom.Next(0,totalcount - 1);
book = reader.GetValue(0).ToString();
datastring = book.ToCharArray();
How does that work ? He wants to read a random value from the DB. This will give him a useless random number, and he will alway end up with the last string in the data base as his selected string.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Oh yes, i didn't thought abt it.
You are rite CG, thanks for telling me.
|
|
|
|
|
nagendrathecoder wrote:
I have doubts on following line:
datastring = book.ToCharArray();
R u sure, this line work?
ANS: Actually "datastring = book.ToCharArray();" this line of code works.....the thing is that i have to randomly select a name from the database and display it on a txtbox....that is wt i was doin....but that code snippet of mine was of no use....the snippet which u hav given me does not take d name randomly.....suggest me how to take names randomly from d database???
Ξ:::...£!ΠŤØ...:::Ξ®
|
|
|
|
|
linto_11 wrote: ANS: Actually "datastring = book.ToCharArray();" this line of code works.....the thing is that i have to randomly select a name from the database and display it on a txtbox....that is wt i was doin....but that code snippet of mine was of no use....the snippet which u hav given me does not take d name randomly.....suggest me how to take names randomly from d database???
Stop using text speak, don't be a retard. You have 101 keys, use them.
I told you already why your code is utterly useless, and shows you have no idea what you're doing. I told you two ways you could make it work the way you want.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hi
Does anyone have a good example I could follow for implementing Named Pipes using WCF? I want to implement one that is bi-directional in a manner that is similar to a web service.
|
|
|
|
|
check around the NetNamedPipeBinding .
Otherwise it's exactly the same as using any other transportation layer in WCF.
|
|
|
|