Showing posts with label stuck. Show all posts
Showing posts with label stuck. Show all posts

Wednesday, March 21, 2012

Please help me I am stuck!

I have a few question on ASP.net accessing database. Can you please help me??
The situation is like this:
There are 2 listbox, listboxA and listboxb. ListboxA contains all the available interviewer's names. Then listboxb contains the selected interviewer's name. Now I need to extract all the name from listboxb and find their corresponding ID in a table call interviewer then insert their corresponding ID to another table call performance. How am I suppose to do that? Secondly is: For example i got 2 sql statement, how do I execute them at the same time, in other words is there any codes that can insert a data into multiple tables and multiple rows to a database?
Can you please help me with it?
I am really stuck on this.here is the code:

I used button press event to insert the ID's from the listb.


if(!Page.IsPostBack)
{
SqlDataAdapter ad = new SqlDataAdapter("SELECT * FROM tblPerson",myConnection);
DataSet ds = new DataSet();
ad.Fill(ds,"tblPerson");

myBox.DataSource = ds;
myBox.DataTextField = "Name";
myBox.DataValueField = "PersonID";
myBox.DataBind();

}
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.myConnection = new System.Data.SqlClient.SqlConnection();
//
// myConnection
//
this.myConnection.ConnectionString = "workstation id=GEEK;packet size=4096;integrated security=SSPI;initial catalog=DBP" +
"erson;persist security info=False";
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void Button1_Click(object sender, System.EventArgs e)
{
foreach(ListItem l in myBox.Items)
{
SqlCommand myCommand = new SqlCommand("ADDPERSON",myConnection);
myCommand.CommandType = CommandType.StoredProcedure;

myCommand.Parameters.Add(new SqlParameter("@.p_ID",SqlDbType.Int,4));
myCommand.Parameters["@.p_ID"].Value = Convert.ToInt32(l.Value);

myConnection.Open();
myCommand.ExecuteNonQuery();
myConnection.Close();

}
}


Thanks alot... but I don't really know how to use StoredProcedure.
Where did you initialise the "ADDPERSON" ?
Is there any website I can look up for reference?
Sorry to trouble you, but thanks alot
Creating Stored Procedures and User-Defined Functions;

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vdbt7/html/dvhowcreatingstoredprocedure.asp

Using Stored Procedures with a Command

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconusingstoredprocedureswithcommand.asp
Here is the stored procedure that I have used:


CREATE PROCEDURE [ADDPERSON]

@.p_ID int

AS

INSERT INTO tblDeveloper(PersonID) VALUES(@.p_ID);
GO

Friday, March 16, 2012

Please help me, and close the darn form!

Hi,
I've been here before and i'm still stuck with the same problem. I just can't close the stupid form.
I'm using microsoft's browser control on my aplication. I can open a new form when i click any link. That works great.

The BIG problem is when the javascript:window.close() is called from any page. The browser control closes, but i get stuck with the form it was on. I just can't close it.

Please help me. I've been to all kind of forums and still haven't found a solution.

Thanks.I think it has something to do with this bug. It looks like the WindowClosing event isn't beeing fired.

Can someone translate this into VB.Net.

http://www.codeproject.com/buglist/iefix.asp

Thanks.
I've never used the WebBrowser control, so I can't help there.

However, here is an onlineC# to VB.NET converter. It will convert the code provided in the article you referenced.

Hope this helps.
I got it. Thanks for your post "SomeNewKid2", but i didn't use that code. To confusing.

I was trying to use the windowclosing event and it didn't work. I found out that it work with the leave handler.
Like this:


Private Sub AxWebBrowser1_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxWebBrowser1.Leave
Me.Close()
End Sub

This closes the stupid form also.
Stay well.