global DataSet and DataAdapter...HOW?

brendalisalowe

New member
Joined
Aug 24, 2004
Messages
2
Programming Experience
1-3
[font=verdana, arial, helvetica]OK, this is my question. If you have a public dataset and dataadapter, do you have to drag and drop a SqlDataAdapter onto each form? How do you set it up? With the same Dataset? With the same columns as Form1 or just the ones I need for that form? Pretty much I have no idea, but I need different forms that will use some of the data from Form1. How do I do that? I am newer at this.

Module:


[/font]
VB.NET:
 [color=#00007f]Public[/color] m_DataSet [color=#00007f]As[/color] DataSet = Nothing  [color=#00007f]Public[/color] m_DataAdapter [color=#00007f]As[/color] SqlClient.SqlDataAdapter = Nothing 
 
[color=#00007f]Public[/color] strConnectionString [color=#00007f]As[/color] [color=#00007f]String[/color] = "Data Source=CRSERVER;Initial Catalog=crdatabase;Integrated Security=SSPI"[font=verdana, arial, helvetica][size=2]
[/size][/font]
[font=verdana, arial, helvetica]Form2:[/font]
VB.NET:
[color=#00007f]Private[/color] [color=#00007f]Sub[/color] PhoneNumbers_Load([color=#00007f]ByVal[/color] sender [color=#00007f]As[/color] System.[color=#00007f]Object[/color], [color=#00007f]ByVal[/color] e [color=#00007f]As[/color] System.EventArgs) Handles MyBase.Load [color=#00007f]Me[/color].Text = "Phone Numbers [color=#00007f]For[/color] [color=#00007f]Case[/color] # " & g_CaseNum & ""  [color=#00007f]Dim[/color] query [color=#00007f]As[/color] [color=#00007f]String[/color] = "SELECT HomePhone,WorkPhone,CellPhone,FaxPhone,OtherPhone,SpousePhone,SpouseWork,SpouseCell,SpouseOther FROM tblCapRec WHERE CaseNumber = '" & g_CaseNum & "' AND PartNumber = " & g_PartNum & "" 
m_DataAdapter = [color=#00007f]New[/color] SqlDataAdapter(query, strConnectionString) 
m_DataSet = [color=#00007f]New[/color] DataSet() m_DataAdapter.Fill(m_DataSet) [color=#00007f]End[/color] [color=#00007f]Sub[/color]
[font=verdana, arial, helvetica]

Any help for me yet? I really just want to get this solved, but I am just not smart enough to do it alone. Thanks!






Brenda
[/font]
 
Last edited:

Rob Mills

Member
Joined
Jun 9, 2004
Messages
6
Programming Experience
Beginner
So you want to use these objects on multiple forms, yes? Why not just modify the properties of these objects with each form?
 
Top Bottom