Convert java code to C#

after getting the resultset in a db java users a setString(int, string

Page 1 of 1

11 Replies - 10267 Views - Last Post: 10 March 2008 - 07:17 AM Rate Topic: -----

#1 bthumber   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 06-March 08

Convert java code to C#

Post icon  Posted 06 March 2008 - 01:12 PM

The Java code:
public int findNumericSeqCode(Connection myConn, String standard, String hostName)
.
.
cs = myConn.prepareCall("{call matchHost(@pHost=?)}");
cs.setString(1, hostName + "[0-9][0-9]");
ResultSet myHosts = cs.executeQuery();
cs is a callable statement.

What is the C# equivalent of a setString()?

Thank
Is This A Good Question/Topic? 0
  • +

Replies To: Convert java code to C#

#2 Nykc   User is offline

  • Gentleman of Leisure
  • member icon

Reputation: 740
  • View blog
  • Posts: 8,654
  • Joined: 14-September 07

Re: Convert java code to C#

Posted 06 March 2008 - 02:33 PM

Hello & welcome to Dream.In.Code
Was This Post Helpful? 0
  • +
  • -

#3 captainhampton   User is offline

  • Jawsome++;
  • member icon

Reputation: 15
  • View blog
  • Posts: 548
  • Joined: 17-October 07

Re: Convert java code to C#

Posted 06 March 2008 - 03:02 PM

Welcome to the Dream in Code community!
(Please be sure to post what you have in the proper section of the forums)
Was This Post Helpful? 0
  • +
  • -

#4 papuccino1   User is offline

  • His name was Robert Paulson.
  • member icon

Reputation: 63
  • View blog
  • Posts: 1,121
  • Joined: 02-March 08

Re: Convert java code to C#

Posted 07 March 2008 - 07:40 AM

Why can't you guys help him? He's not asking for the whole code, he just wants the equivalent function of "setString()".

Jesus.

This post has been edited by papuccino1: 07 March 2008 - 08:50 AM

Was This Post Helpful? 0
  • +
  • -

#5 baavgai   User is offline

  • Dreaming Coder
  • member icon


Reputation: 7507
  • View blog
  • Posts: 15,558
  • Joined: 16-October 07

Re: Convert java code to C#

Posted 07 March 2008 - 08:04 AM

View Postpapuccino1, on 7 Mar, 2008 - 09:40 AM, said:

Community my ass. Why can't you guys help him? He's not asking for the whole code, he just wants the equivalent function of "setString()".


Actually, no.

He's looking for database code equating to prepareCall, which is not a trivial answer. The way the question is phrased would lead anyone with expirience to believe that the Q&A session following any answer would be long, drawn out, and painful. The question shows not just an unfamiliarity with C#, but also Java and OO in general. Answering such a question is like sliding down a hill razor blades into a pool of alcohol. Any sane person whould shy away.

Ok, coffee has kicked in. This is all I'll say:

The answer would be to look all the DbCommand interface. Better yet, actually read something about C# database connections. PsychoCoder's tutorial OleDb Data Objects in C# has the answer, for instance.

Good luck.
Was This Post Helpful? 0
  • +
  • -

#6 PsychoCoder   User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1663
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Convert java code to C#

Posted 07 March 2008 - 08:24 AM

View Postpapuccino1, on 7 Mar, 2008 - 06:40 AM, said:

Community my ass. Why can't you guys help him? He's not asking for the whole code, he just wants the equivalent function of "setString()".

Jesus.


WTF??!! I went and looked at the threads you started and all your questions were answered, so I don't understand you're reaction here


EDIT: and this is a community, we volunteer our time, free I might add, to help people the best we can. We are not, however, here to just do peoples work. As baavgai stated, if he knew anything about Java, C# or OO he would know where to start, then if he ran into trouble after that he could have asked for help.

We push people to solve their problems, we are here to help after they've at least tried to solve it themselves. If they cant help themselves how are they going to make it in the real world as a programmer?

This post has been edited by PsychoCoder: 07 March 2008 - 08:27 AM

Was This Post Helpful? 0
  • +
  • -

#7 papuccino1   User is offline

  • His name was Robert Paulson.
  • member icon

Reputation: 63
  • View blog
  • Posts: 1,121
  • Joined: 02-March 08

Re: Convert java code to C#

Posted 07 March 2008 - 08:27 AM

View PostPsychoCoder, on 7 Mar, 2008 - 08:24 AM, said:

View Postpapuccino1, on 7 Mar, 2008 - 06:40 AM, said:

Community my ass. Why can't you guys help him? He's not asking for the whole code, he just wants the equivalent function of "setString()".

Jesus.


WTF??!! I went and looked at the threads you started and all your questions were answered, so I don't understand you're reaction here


Yeah, you guys did help me! And I'm massively thankful! I'm just annoyed that someone asks a simple question that isn't even asking for full code, and some of you just type: "Please use [code] for your questions"

If he's asking it means that he doesn't know. Why not help someone out? :v:

Edit: Here's his question again:
What is the C# equivalent of a setString()?

I would answer him if I knew. And I know the answer isn't more than 3 lines. :S

This post has been edited by papuccino1: 07 March 2008 - 08:29 AM

Was This Post Helpful? 0
  • +
  • -

#8 PsychoCoder   User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1663
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Convert java code to C#

Posted 07 March 2008 - 08:30 AM

Well, from the way the post is worded its pretty clear that he hasn't even made an attempt at helping himself. We don't mind helping people, in fact the majority of us do it because we love to. But what we don't like is someone who doesn't even make an attempt to solve a problem, someone who just expects his questions to be answered just because he asked. Thats not how the real world works :)
Was This Post Helpful? 0
  • +
  • -

#9 papuccino1   User is offline

  • His name was Robert Paulson.
  • member icon

Reputation: 63
  • View blog
  • Posts: 1,121
  • Joined: 02-March 08

Re: Convert java code to C#

Posted 07 March 2008 - 08:34 AM

So if I asked for instance:
"What is the equivilant of print() in C++?"

You wouldn't answer me? How can I attempt something when I don't even know the function? Everyone starts out somewhere. :)

View Postbaavgai, on 7 Mar, 2008 - 08:04 AM, said:

Answering such a question is like sliding down a hill razor blades into a pool of alcohol.


THAT sounded painful! :ph34r: :ph34r: :ph34r:
Was This Post Helpful? 0
  • +
  • -

#10 baavgai   User is offline

  • Dreaming Coder
  • member icon


Reputation: 7507
  • View blog
  • Posts: 15,558
  • Joined: 16-October 07

Re: Convert java code to C#

Posted 07 March 2008 - 08:50 AM

View Postpapuccino1, on 7 Mar, 2008 - 10:27 AM, said:

Edit: Here's his question again:
What is the C# equivalent of a setString()?

I would answer him if I knew. And I know the answer isn't more than 3 lines. :S


I already answered this. :P
Was This Post Helpful? 0
  • +
  • -

#11 PsychoCoder   User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1663
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Convert java code to C#

Posted 07 March 2008 - 09:05 AM

View Postpapuccino1, on 7 Mar, 2008 - 07:34 AM, said:

So if I asked for instance:
"What is the equivilant of print() in C++?"


If you asked that question, without any preface as he did, my first thought would be why you didn't use Google. If you had you would at least have something to show you tried. Had he tried Google he would have found his answer here

All we ask is that someone try before abandoning it and wanting someone else to give them what they need before even attempting to figure out themselves :)
Was This Post Helpful? 0
  • +
  • -

#12 zakary   User is offline

  • D.I.C Regular
  • member icon

Reputation: 27
  • View blog
  • Posts: 427
  • Joined: 15-February 05

Re: Convert java code to C#

Posted 10 March 2008 - 07:17 AM

I answered this once on a different thread. setString() in java a prepared statement used for SQL which is like

public int setString(long pos,
                     java.lang.String s);



check this link out for the C# setString Method it takes one more parameter
http://msdn2.microso...513(VS.85).aspx
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1