从另一个页面将C#连接到SQL [英] Connect C# to SQL from another page

查看:68
本文介绍了从另一个页面将C#连接到SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友



我在项目表格1和表格2中有两页。



I在form1中创建一个函数并用sql server连接

现在我想从另一个页面形式调用该函数2.任何人都可以帮助我。

Dear Friends

I have two page in project Form 1 and Form 2.

I have create a function in form1 and connect that with sql server
now I want to call that function from another page form 2. can anybody help me .

推荐答案

您好,



您必须更改Form1



Hello ,

You have to change Form1

public partial class Form1
{

}











To

public class Form1
{

}





然后你可以使用Form1创建新对象,因为Form1 frm = new Form1();在Form2然后



frm.FunctionName();像这样你可以使用。



and then you can use Form1 to create new object as Form1 frm = new Form1(); in Form2 and then

frm.FunctionName(); like this you can use.


这篇关于从另一个页面将C#连接到SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆