|
I don't know what do you mean by sqlhelper class but for ExecuteNonQuery , when you assign a Parameter to your SqlCommand as I told you in other thread , when you excute this function , output parameters fill automaticlly and you can get them.
Mazy
"I think that only daring speculation can lead us further and not accumulation of facts." - Albert Einstein
|
|
|
|
|
Hi,
SQLHelpder class is given in "Data Access Application Block". This block sample code is availabe on
Microsoft MSDN. Why am I using this becuase of time saving. Useful overloads are available to do more in less time.
What I need in a form is the newly added IDs in a table. For example I wrote the following code
//This module will insert a new role in the tblRole table by calling the stored procedure uspRoleNew
SqlParameter[] arparam = new SqlParameter[9];
arparam[0] = new SqlParameter("@pRoleName",SqlDbType.VarChar, 50);
arparam[0].Value= mRoleName;
arparam[1] = new SqlParameter("@pRoleDesc", SqlDbType.VarChar,50);
arparam[1].Value= mRoleDescription;
.
.
. .
arparam[8] = new SqlParameter("@pRoleIDout", SqlDbType.Int);
arparam[8].Direction=ParameterDirection.Output;
SqlHelper.ExecuteNonQuery(clsGeneral.conStr, "uspRoleNew", arparam);
int _RoleID;
_RoleID = (int)arparam[8].Value;
In paramerter[8] i want the newly added ID. But SqlHelper is not returning any value.
Below is the alternative solution for the above problem
mSqlCommand.Connection= _Sqlconn;
mSqlCommand.CommandText="uspRoleNew";
mSqlCommand.CommandType=CommandType.StoredProcedure;
mSqlCommand.Parameters.Add("@pRoleName",SqlDbType.VarChar, 50);
mSqlCommand.Parameters[0].Value=mRoleName;
mSqlCommand.Parameters.Add("@pRoleDesc", SqlDbType.VarChar,50);
mSqlCommand.Parameters[1].Value= mRoleDescription;
mSqlCommand.Parameters.Add("@pRoleIDout", SqlDbType.Int);
mSqlCommand.Parameters["@pRoleIDout"].Direction= ParameterDirection.Output;
_Sqlconn.Open();
mSqlCommand.ExecuteNonQuery();
mRoleID = (int)mSqlCommand.Parameters["@pRoleIDout"].Value;
return mRoleID;
QUESTION ????? is Why sqlhelper not doing this. If u r aware of "Data Access Application Block" plz reply.
|
|
|
|
|
Hi,
I want to refer the sqlparameter object to sqlcommand object. how can i do that ? I am giving different parameters input, return and output.
regards,
abid
|
|
|
|
|
abidkayani1 wrote:
I want to refer the sqlparameter object to sqlcommand object. how can i do that ?
See SqlCommand.Parameters property. There is an example in MSDN.
Mazy
"I think that only daring speculation can lead us further and not accumulation of facts." - Albert Einstein
|
|
|
|
|
In addition to what Mazdak said about using the SqlCommand.Parameters dictionary to refer to parameters by name, it is faster and far better to save the params as variables when you add them and use those variables to refer to them later. No lookups in the Parameters dictionary are needed, then.
See the example[^] I wrote just yesterday.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi there ,
I have a question about the treeview control in .NET.
In my first form I create nodes dynamically.
In my second form I want to show the tree exactly like in the first form.
When I try to pass the treeview like this :
Form2 frm2 = new Form2();
frm2.treeView1 = this.treeView1;
I can see the nodes (when debugging and using quickwatch) of the new tree which are the same of the form1's tree.
The problem is that I cannot display them. Anyone to help me pls?
|
|
|
|
|
Your passing a reference to the first Treeview control, your not copying it. In fact, you CAN'T copy a Treeview control. The Nodes property of the Treeview is read only, so your are limited to recursively walking through the Nodes tree on your first Treeview and using the second Treeview's Add method to add the Nodes to the second tree.
RageInTheMachine9532
|
|
|
|
|
Hi All!!!
I want to show only the shape of my form which i specify e.g. i would liek to draw a form like triagle or in circle or any opolygon. How would i do that rest of the form becomes transparent and only this portion is shown?
Thanx in advance
sorry for my bad English.
|
|
|
|
|
You can start by reading up on non-rectangular forms here[^].
RageInTheMachine9532
|
|
|
|
|
i have the following code, this code will fetch me the http text only without the pictures so how can i get the pictures
<br />
WebProxy proxyObject = new WebProxy();<br />
<br />
proxyObject.BypassProxyOnLocal = true;<br />
GlobalProxySelection.Select = proxyObject;<br />
WebRequest req = WebRequest.Create(url);<br />
WebResponse result = req.GetResponse();<br />
Stream ReceiveStream = result.GetResponseStream( ) ;<br />
StreamReader sr = new StreamReader( ReceiveStream ) ;<br />
Char[] read = new Char[256];<br />
int count = sr.Read( read, 0, 256 );<br />
while ( count > 0 ) <br />
{<br />
String str = new String(read, 0, count);<br />
Response.Write(str);<br />
count = sr.Read(read, 0, 256);<br />
}<br />
Mhmoud Rawas
------------
Software Eng.
|
|
|
|
|
Use regular expressions or complex string comparisons (obviously, the former is recommended) to find all supported attributes for linked content, such as SRC and HREF (in a LINK element, not an A element). If a BASE is in the header, be sure to resolve the URLs with that, otherwise use the current directory of the HTML document. Combine the absolute and relative paths (the Uri constructor does a good job of this, so see the Uri class documentation) and then download the content.
FYI, it may be much easier to read this into an IHTMLDocument2 and use MSHTML to save it for you, since it intrinsically knows all the linked content. See Reusing MSHTML[^] for more information. Experience with COM will be helpful.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
How do you show properties of an object in a object collection editor,
eg. Panels collection???
|
|
|
|
|
You'll have to ellaborate a little on this...
Are you talking about DesignTime or RunTime?
Are you looking at extending the VS.NET Environment to include your own custom property UI Editor?
RageInTheMachine9532
|
|
|
|
|
How come this doesn't work? He doesn't save the data you edit in the datagrid
Thx in advance!
private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{ //get the node out of the xml-file
string pad = "//school[@naam='" + comboBox1.SelectedItem.ToString() + "']";
XmlDocument xml = new XmlDocument();
xml.Load(@"c:\nodes.xml");
XmlNodeList contactNodes = xml.SelectNodes(pad);
string box = contactNodes.Item(0).OuterXml;
//write the node to a new file so it can be loaded into a dataset
xml.LoadXml(box);
XmlTextWriter xmltw = new XmlTextWriter(@"c:\testnodes.xml",new UTF8Encoding(false));
xml.WriteTo(xmltw);
xmltw.Close();
DataSet ds = new DataSet();
ds.ReadXml(@"c:\testnodes.xml");
dataGrid1.DataSource = ds;
dataGrid1.DataMember = "school";
}
private void button1_Click(object sender, System.EventArgs e)
{
ds.WriteXml(@"c:\testnodes.xml");
}
|
|
|
|
|
Call dataGrid1.DataBind() function after setting DataSource property.
|
|
|
|
|
it sais that function doesn't exist
'System.Windows.Forms.DataGrid' does not contain a definition for 'DataBind'
DataBindings is in the list but i don't know how to use that
anyway thx for your answer
|
|
|
|
|
Sorry DataBind is for Asp.Net datagrid
DataSet ds = new DataSet();
ds.ReadXml(@"c:\testnodes.xml");
dataGrid1.SetDataBinding(ds, "school");
You can find it here
|
|
|
|
|
thx! i tried it but it still doesn't save the data in the datagrid
|
|
|
|
|
In your code you always write testnodes.xml file getting info from nodes.xml on comboBox1_SelectedIndexChanged . So you read data from one file, select, and than write to another file?(button1_Click ).
|
|
|
|
|
yes that's right,
later on i will take the node from testnodes.xml en place it back into nodes.xml
|
|
|
|
|
Hello,
I have a question of customizing the tree node of .NET FrameWork.
How can I add a picture box to treenode towards right side of the
treenode text.
Bye.
|
|
|
|
|
This is an incredibly difficult task because the TreeView is responsible for drawing the entire surface, not like pieces of it like a ListView . Like other controls, the TreeView encapsulates its common controls equivalent, namely the Tree-View. This class was not designed with owner drawing in mind.
Many attempts have been made to owner draw the tree, but none are very good at all. You're much better off using a third-party control like that from http://www.infragistics.com[^] (UltraWinTree). We use it for our products and it's very extensible with a drawing model that's easy to extend.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I want to know how to change the font, or size of MessageBox.
Help me please.
Thanks in advance.
Mr Duc Linh Nguyen
|
|
|
|
|
You can't, not without changing the system font. It encapsulates native calls, namely the MessageBox native API.
If you want a different look, create your own Form and make it work similarly if you like.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello,
Now I develop a dialog included splitter control.
After moving splitter control, I regist splitter location
in registry. In this case, I get location using splitter_moving event(SplitterEventArgs).
And I restart this dialog.
I set location. The following is setting code.
this.splitter1.Location = new Point(x,y);
But I couldn't.
I think this solution is no problem.
If you have some ideas, please tell me.
regards,
yu-yu
|
|
|
|