9 Replies - 4418 Views - Last Post: 13 January 2009 - 12:36 PM Rate Topic: -----

#1 bunny20   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 29-December 08

vb codes equivalent to c#

Post icon  Posted 12 January 2009 - 07:58 AM

Can anyone tell me what's the equivalent of this vb codes in c#?

Private Sub cmdAddSave_Click()
Dim rs As New ADODB.Recordset
rs.Open "Select * From UserAccount", Conn, 3, 3
With rs rs.AddNew
	 rs!UserName = txtUserName.Text
	 rs!LastName = txtLastName.Text
	 rs!FirstName = txtFirstName.Text
	 rs!MiddleName = txtMiddleInitial.Text
	 rs!Age = txtAge.Text
	 rs!Gender = cboGender.Text
	 rs!Password = txtPassword.Text
	 rs.Update
	 MsgBox "New User Account Successfully Sav"
	ed", vbInformation + vbOKOnly, "User Name"
	 End With
  Set rs = Nothing
End Sub



it's a great help...

thank you...

Is This A Good Question/Topic? 0
  • +

Replies To: vb codes equivalent to c#

#2 dklingman   User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 263
  • Joined: 23-December 08

Re: vb codes equivalent to c#

Posted 12 January 2009 - 09:59 AM

click here

sorry ignore that link! i looked at the code to quick and didn't realize that it was vb6 code and not vb.net
Was This Post Helpful? 0
  • +
  • -

#3 bunny20   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 29-December 08

Re: vb codes equivalent to c#

Posted 12 January 2009 - 09:53 PM

please someone gave me an equivalent of the above codes in C#.....

That was my project last semester in VB6 and I want to convert it in C# but since I'm new in C# I don't know the equivalents of those codes....

It's really a great , great , great help if you can provide an equivalent...
Was This Post Helpful? 0
  • +
  • -

#4 b.ihde   User is offline

  • D.I.C for life
  • member icon

Reputation: 45
  • View blog
  • Posts: 1,070
  • Joined: 29-September 08

Re: vb codes equivalent to c#

Posted 13 January 2009 - 01:36 AM

Hi! I m not a C# pro but maybe i can help a little bit.. I m also not at work so i cannot
use C# right now.. All i can do is to try.. :/

I m sure this have to be modified a little bit to get the right answer..

But let me try:

private void cmdAddSave_Click(object Sender, EventArgs e)
Recordset rs = new Recordset(); // donīt really know whatīs: ADODB.
rs.Open(UserAccount, Conn, 3, 3); // donīt really know how to convert: "Select * From UserAccount", Conn, 3, 3
	 rs.Add(UserName, LastName, FirstName, MiddleName, Age, Gender, Password);
	 UserName = txtUserName.Text
	 LastName = txtLastName.Text
	 FirstName = txtFirstName.Text
	 MiddleName = txtMiddleInitial.Text
	 Age = txtAge.Text
	 Gender = cboGender.Text
	 Password = txtPassword.Text

	 rs.Update();

	 MessageBox.Show("New User Account Successfully Sav");
	 ed", vbInformation + vbOKOnly, "User Name" // whatīs ed??? maybe the MessageBoxdetails?Then it would be:

		string message = "New User Account Successfully Sav\r\n" + txtUsername.Text;
		string caption = "User Account";
		MessageBoxButtons buttons = MessageBoxButtons.OK;
		MessageBoxIcon icon = MessageBoxIcon.Information;

	 MessageBox.Show(message, caption, buttons, icon);

  Set rs = Nothing // I donīt know again..



I hope this helps you a little bit, or just helps other to complete it...

regards

B.Ihde
Was This Post Helpful? 0
  • +
  • -

#5 bunny20   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 29-December 08

Re: vb codes equivalent to c#

Posted 13 January 2009 - 01:52 AM

View Postb.ihde, on 13 Jan, 2009 - 12:36 AM, said:

Hi! I m not a C# pro but maybe i can help a little bit.. I m also not at work so i cannot
use C# right now.. All i can do is to try.. :/

I m sure this have to be modified a little bit to get the right answer..

But let me try:

private void cmdAddSave_Click(object Sender, EventArgs e)
Recordset rs = new Recordset(); // donīt really know whatīs: ADODB.
rs.Open(UserAccount, Conn, 3, 3); // donīt really know how to convert: "Select * From UserAccount", Conn, 3, 3
	 rs.Add(UserName, LastName, FirstName, MiddleName, Age, Gender, Password);
	 UserName = txtUserName.Text
	 LastName = txtLastName.Text
	 FirstName = txtFirstName.Text
	 MiddleName = txtMiddleInitial.Text
	 Age = txtAge.Text
	 Gender = cboGender.Text
	 Password = txtPassword.Text

	 rs.Update();

	 MessageBox.Show("New User Account Successfully Sav");
	 ed", vbInformation + vbOKOnly, "User Name" // whatīs ed??? maybe the MessageBoxdetails?Then it would be:

		string message = "New User Account Successfully Sav\r\n" + txtUsername.Text;
		string caption = "User Account";
		MessageBoxButtons buttons = MessageBoxButtons.OK;
		MessageBoxIcon icon = MessageBoxIcon.Information;

	 MessageBox.Show(message, caption, buttons, icon);

  Set rs = Nothing // I donīt know again..



I hope this helps you a little bit, or just helps other to complete it...

regards

B.Ihde


It's okay...anyway thank you for the effort of helping me...
I will try the code....:) :)

Thanks again...
Was This Post Helpful? 0
  • +
  • -

#6 dklingman   User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 263
  • Joined: 23-December 08

Re: vb codes equivalent to c#

Posted 13 January 2009 - 06:11 AM

i don't know exactly what you're using as for you're connection string and/or the ado.net provider you're using but this should get you started.

			System.Data.OleDb.OleDbConnection cnn = new System.Data.OleDb.OleDbConnection("the connection string");

			cnn.Open();
			System.Data.OleDb.OleDbDataAdapter da = new System.Data.OleDb.OleDbDataAdapter("Select * From UserAccount",cnn);
			System.Data.OleDb.OleDbCommandBuilder builder = new System.Data.OleDb.OleDbCommandBuilder(da);
			
			DataTable dt = new DataTable("theTable");

			da.Fill(dt);
			
			DataRow dr = dt.NewRow();

			dr["UserName"] = txtUserName.Text;
			dr["LastName"] = txtLastName.Text;
			dr["FirstName"] = txtFirstName.Text;
			dr["MiddleName"] = txtMiddleInitial.Text;
			dr["Age"] = txtAge.Text;
			dr["Gender"] = cboGender.Text;
			dr["Password"] = txtPassword.Text;
			dt.Rows.Add(dr);

			da.InsertCommand = builder.GetInsertCommand();
			da.Update(dt);
			dt.Dispose();
			dt = null;
			da.Dispose();
			da = null;
			cnn.Close();
			cnn.Dispose();
			cnn = null;


Was This Post Helpful? 0
  • +
  • -

#7 b.ihde   User is offline

  • D.I.C for life
  • member icon

Reputation: 45
  • View blog
  • Posts: 1,070
  • Joined: 29-September 08

Re: vb codes equivalent to c#

Posted 13 January 2009 - 06:18 AM

Thank god, that we have some competent use here :D
Was This Post Helpful? 0
  • +
  • -

#8 dklingman   User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 263
  • Joined: 23-December 08

Re: vb codes equivalent to c#

Posted 13 January 2009 - 07:33 AM

View Postb.ihde, on 13 Jan, 2009 - 08:18 AM, said:

Thank god, that we have some competent use here :D



no one ever said i was competent, i mean look at me with that hat on :blink: :crazy: :P

This post has been edited by dklingman: 13 January 2009 - 07:33 AM

Was This Post Helpful? 0
  • +
  • -

#9 JackOfAllTrades   User is offline

  • Saucy!
  • member icon

Reputation: 6260
  • View blog
  • Posts: 24,030
  • Joined: 23-August 08

Re: vb codes equivalent to c#

Posted 13 January 2009 - 09:18 AM

View Postbunny20, on 12 Jan, 2009 - 11:53 PM, said:

please someone gave me an equivalent of the above codes in C#.....

That was my project last semester in VB6 and I want to convert it in C# but since I'm new in C# I don't know the equivalents of those codes....

It's really a great , great , great help if you can provide an equivalent...


Perhaps, if you want to learn C#, you should actually make an attempt at doing so rather than just coming to DIC and asking someone to do it for you.

If you don't want to actually *learn* C#, then I would say you should hire someone if you're unwilling to even give it a try.
Was This Post Helpful? 0
  • +
  • -

#10 b.ihde   User is offline

  • D.I.C for life
  • member icon

Reputation: 45
  • View blog
  • Posts: 1,070
  • Joined: 29-September 08

Re: vb codes equivalent to c#

Posted 13 January 2009 - 12:36 PM

View Postdklingman, on 13 Jan, 2009 - 06:33 AM, said:

no one ever said i was competent, i mean look at me with that hat on :blink: :crazy: :P


I said so! haha but you re right, when i look at your hat... I really have to think about it again :P
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1