hoe to use stored procedure and dll with mysql database,kindly give some ideas

Posted by Jerome under ASP.NET on 3/18/2012 | Points: 10 | Views : 1500 | Status : [Member] | Replies : 4
how to use mysql database with stired procedure and with the use of dll




Responses

Posted by: Rajni.Shekhar on: 3/21/2012 [Member] Bronze | Points: 25

Up
0
Down
Do you have a specific dll to connect with database? or want to create a dll? please tell me details... so that someone can help you.

Thanks,
Rajni Shekhar

Jerome, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jerome on: 3/21/2012 [Member] Starter | Points: 25

Up
0
Down
I want to create a dll of my own...even a simple dll will do, I just want to figure out the process....thanks!

Jerome, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajni.Shekhar on: 3/22/2012 [Member] Bronze | Points: 25

Up
0
Down
OK, dll can be any execution file, you can create a project/website/class library/web application. So here i am just explaining dll of Class Library

1) Click on file menu -> New-> Project -> Class Library (you can select your language VB or C#)
2) name it SampleDll
3) there would be class1.cs (You can change class name as SampleClass as i did in following example)
4) write any database related code here.

Add two namespace to connect with database (I am taking here sqlclient for sql server)

using System.Data;
using System.Data.SqlClient;

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace ClassLibrary1
{
public class SampleClass
{
SqlConnection conn = null;
SqlCommand cmd = null;
public bool RunProcedure()
{
try
{
conn = new SqlConnection("Server=(local);DataBase=Northwind;Integrated Security=SSPI");
conn.Open();
cmd = new SqlCommand();
cmd.CommandText = "SampleStoredProcedure"; //
cmd.CommandType = CommandType.StoredProcedure;
cmd.ExecuteNonQuery();
return true;
}
catch (Exception objEx)
{
throw objEx;
}
finally
{
if (conn!=null)
{
conn.Close();
conn = null;
}
if (cmd != null)
{
cmd = null;
}
}
}

}
}


now build project in release mode.

Go to your project folder->bin folder->Release Folder-> there would be a dll

Now you can use it as private of public assembly.

Thanks,
Rajni Shekhar

Jerome, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 3/22/2012 [Member] Bronze | Points: 25

Up
0
Down
Dll Creation


1st,New Project-->Open ClassLibrary

Changes in Class
    using System;

using System.Collections.Generic;
using System.Text;

namespace Cls_Lib
{
public class ClassA
{
public int a= 10;

public void Multiply()
{
a+= 2;
}

public void add(int b)
{
a += b;
}

}


2nd,Dont close the Old Project , right-clicking on the Solution Explorer
add-->Newproject & Rightclick on your
Newproject ->add reference->choose tab->Project and add.
using System;
using System.Collections.Generic;
using System.Text;
using Cls_Lib --> Ur Dll
 namespace Result

{
class Program
{
static void Main(string[] args)
{
ClassA a= new ClassA();
a.a= 9;
a.add(9);
Console.WriteLine(a.a);
Console.ReadLine();
}
}
}


Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Jerome, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response