Click here to Skip to main content
15,900,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi.. friends i have a code in c# but I have no deeply knowledge in vb.net so plz anyone can convert the the below code into vb.net code

VB
public void save_rec(string spname, SqlParameter[] p)
        {

            SqlConnection con = new SqlConnection("Data Source=PRANSHU\\SQLEXPRESS;Initial Catalog=test2;User ID=sa;Password=Webnsoft1");
            SqlDataAdapter adp=new SqlDataAdapter(spname,con);
            adp.SelectCommand.CommandType=CommandType.StoredProcedure;
            DataSet ds=new DataSet();
            for(Int32 i=0;i<p.length;i++)>
            {

                adp.SelectCommand.Parameters.Add(p[i]);
            }
            adp.Fill(ds);
        }


VB
clstest obj = new clstest();
            SqlParameter[] p = { new SqlParameter("@ename", SqlDbType.VarChar, 50), new SqlParameter("@eadd", SqlDbType.VarChar, 50) };
            p[0].Value = textBox1.Text;
            p[1].Value = textBox2.Text;
            obj.save_rec("insemployee", p);
            MessageBox.Show("save");


Thanks in advance

Parveen Rathi
Posted
Updated 30-Aug-11 23:41pm
v2

Try this:

http://www.developerfusion.com/tools/convert/vb-to-csharp/[^]

here you can convert from vb to c# and vice-versa.

hope it helps :)
 
Share this answer
 
v2
Comments
Parveen Rathi 31-Aug-11 6:03am    
Thanks sir my problem has been solved

Thanks
Uday P.Singh 31-Aug-11 10:09am    
If it helps, then you can accept the answer anytime.
please see: C# to VB Converter
 
Share this answer
 
Comments
the headless nick 5-Oct-11 8:36am    
nice post
Most of the code is the same but

C#
private void save_rec(string spName, SqlParameter[] p)
{

}


becomes

VB
public sub save_rec(byval spName as string, p as sqlparameter())
end sub


Varaible Declarations

C#
sqlconnection con = new sqlconnection();


becomes

VB
dim con as sqlconnection = new sqlconnect("connectionStringHere")



For loops

C#
for(Int32 i=0;i<p.length;i++)>
{
}


become

VB
for i as integer = 0 to p.length -1
next


But please note that the converters don't convert between them well so you may have to manually change some code. telrik Converter[^]
 
Share this answer
 
VB
Public Function save_rec(ByRef spname As String, ByRef p As SqlParameter())

        Dim con As SqlConnection = New SqlConnection("Data Source=PRANSHU\\SQLEXPRESS;Initial Catalog=test2;User ID=sa;Password=Webnsoft1")
        Dim adp As SqlDataAdapter = New SqlDataAdapter(spname, con)
        adp.SelectCommand.CommandType = CommandType.StoredProcedure
        Dim ds As DataSet = New DataSet()
        For i = 0 To p.Length
            adp.SelectCommand.Parameters.Add(p(i))
        Next
        adp.Fill(ds)
        Return vbNull
    End Function


VB
Dim obj As clstest = New clstest()
        Dim p As SqlParameter() = {New SqlParameter("@ename", SqlDbType.VarChar, 50), New SqlParameter("@eadd", SqlDbType.VarChar, 50)}
        p(0).Value = TextBox1.Text
        p(1).Value = textBox2.Text
        obj.save_rec("insemployee", p)
        MessageBox.Show("save")


Good Luck!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900