|
I would like to know how to add data into 2 tables in one procedure. I have table1 and table2. Now i insert data to first table, but i have problems with inserting ID(auto-increment) of first table into second table.
I have procedure like this but it doesn't work:
<br />
ALTER procedure dbo.insert_test<br />
<br />
<br />
@value1,<br />
@value2,<br />
@value3<br />
<br />
as<br />
<br />
declare @table_1 int<br />
<br />
insert into table1(value1,value2,value3) values(@value1,@value2,@value3)<br />
<br />
SET @table_1 = (SELECT table1.ID FROM table1) --> table1.ID is primary key<br />
<br />
insert into table2(table_1, value2) values(@table_1, @value2) --> @value2 is same as for table1<br />
Thanks
|
|
|
|
|
First, there is a database forum here which would have been a better place to ask this than the ASP.NET forum don't you think?
I'm assuming you are trying are trying to join these two tables via the table_1 column.
SET @table_1 = (SELECT table1.ID FROM table1 )
This will only return the first id in this table, not that last one inserted. This what you want.
SET @table_1 = SCOPE_IDENTITY()
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
|
hy,
i have a requirement in which i ahve to open a pop up form main page...and soon as i click on save on the popup...the particular record that i inserted into the popup should automatically be shown in the dropdown in the main page...this should happen ithout any event being fierd in the main page.
thanks and regards,
raghvendra panda
|
|
|
|
|
|
|
Thnks A lot man....itz working fine
|
|
|
|
|
Hi,
I want to use the Cascading dropdown control that populate from SQLServer database tables.
If any body have it's working code so please help me.
Thanks for your reply
Regards
Ratnesh Nirmal Bharos
( Web Developer Asp.net, C#)
|
|
|
|
|
|
|
I'm trying to validate an image before uploading to the server. Basically I want to validate the image width and height before uploading. I have seen this done before using javascript but thought maybe someone would have another solution?
ASP all the way
|
|
|
|
|
Well if you want it done prior to uploading then I'm afraid that javascript is your only method. Can't access a file server side without it being there after all.
Of course people disabling javascript would get around this so, you should really have a redundant check on the server side anyway.
|
|
|
|
|
thanks i see the problem. thanks for the advice tho.
ASP all the way
|
|
|
|
|
In Asp.NET you can check image file's height and width
before uploading it using following code.
Dim upBmp As Bitmap = Bitmap.FromStream(FileUpload1.PostedFile.InputStream)
Dim upWidth As Integer = upBmp.Width
Dim upHeight As Integer = upBmp.Height
But for that you need server trip.
So best way is using javascript.
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
I'll try this method and see if it works for my scenario. thanks
ASP all the way
|
|
|
|
|
hi,
i have a we application and i have different settings for this application,
now i need multiple web.config files in the application,
how i can reference to those web.config files melodramatically at run time that which one's settings is going to be used this time,
can any body explain it please,
|
|
|
|
|
|
The usage of multiple configuration file makes the application more secure and manageable.
In the following tutorial you can learn how to use multiple web.config files in your application.
Regards,
Jamil
|
|
|
|
|
Hi, I want to return selected items (check box list) on button click of a user control to the parent page.
How do I do this ? The checked items would be in form of List<>.
I have made the user control but don't know how to pass an input id to it to fetch the records and on button click, return them.
|
|
|
|
|
Just make one public method of your user control
which returns List<> items [Contains selected items].
That's it. You need to access that particular method once
button click is over.
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
Update:
Ok, I created two public properties, now I want to return the selected checkbox items in the checkbox list and return them on button click so I used a foreach, not much sure about my approach.Here is how its looking now. How to bind the results with parent page gridview on user control button click ?
public partial class assets_WebControls_ftExclusions : System.Web.UI.UserControl
{
private int id;
private ftExclusionsList myftExclusions;
public int ID
{
get{return ID;}
set{ID=value;}
}
public ftExclusionsList selectedExclusions
{
get { return myftExclusions; }
set { myftExclusions = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
cblExclusions.DataBind();
ftExclusionsList myExcluList = ftExclusionsManager.ftExclusionsById(ID);
if (myExcluList != null)
{
if (myExcluList.Count > 0 && myExcluList != null)
{
foreach (ftExclusions ex in myExcluList)
{
cblExclusions.Items.FindByValue(ex.excluId.ToString()).Selected = true;
}
}
}
}
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
ftExclusionsList myFTExclusionList = new ftExclusionsList();
foreach (ListItem li in cblExclusions.Items)
{
if (li.Selected == true)
{
ftExclusions myftExclusion = new ftExclusions();
myftExclusion.ftExcluId = Convert.ToInt32(li.Value);
myftExclusion.excludesc = li.Text.ToString();
myFTExclusionList.Add(myftExclusion);
}
}
selectedExclusions = myFTExclusionList;
}
}
modified on Friday, May 28, 2010 7:53 AM
|
|
|
|
|
Hi
I want to make my website url like
www.websitename.com/username
Just like twitter in which we have
twitter.com/username
How to achieve this
Please help
Thanks in advance
|
|
|
|
|
|
hi to all,
i am new in asp.net,
i want to create parameterised crystal report. i did it i create parameter "Empid " using "Parameter Fields"
then i want to show the report on click event of button so code is as follows,
<br />
Protected Sub btnShow_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnShow.Click <br />
Dim ConnInfo As New ConnectionInfo <br />
With ConnInfo <br />
.ServerName = ".sqlexpress" <br />
.DatabaseName = "Northwind" <br />
.UserID = "sa" <br />
.Password = "" <br />
End With <br />
<br />
Me.CrystalReportViewer1.ParameterFieldInfo.Clear() <br />
If Me.txtEmployeeID.Text.Trim.Length > 0 Then <br />
Me.CrystalReportViewer1.ReportSource = Server.MapPath("SampleParam1.rpt") <br />
Dim ParamFields As ParameterFields = Me.CrystalReportViewer1.ParameterFieldInfo <br />
Dim p_EmpID As New ParameterField <br />
p_EmpID.Name = "p_EmployeeID" <br />
Dim p_EmpID_Value As New ParameterDiscreteValue <br />
p_EmpID_Value.Value = Me.txtEmployeeID.Text <br />
p_EmpID.CurrentValues.Add(p_EmpID_Value) <br />
ParamFields.Add(p_EmpID) <br />
Else <br />
Me.CrystalReportViewer1.ReportSource = Server.MapPath("SampleRpt01.rpt") <br />
End If <br />
<br />
For Each cnInfo As TableLogOnInfo In Me.CrystalReportViewer1.LogOnInfo <br />
cnInfo.ConnectionInfo = ConnInfo <br />
Next <br />
Me.CrystalReportViewer1.RefreshReport() <br />
End Sub <br />
i am using sql2000, but after the clicking on button it will show me an error ,"Object Reference not set to an instance of an object".
why i gives me error?
is the servername is wrong? what the name should i provide? my database is on another computer and i am accessing it through networking
the name of the computer is "RS1" so should i give the servername="RS1"
if i debug the code , CrystalReportViewer1.LogOnInfo have count=0.
what is error?
|
|
|
|
|
i have below code.
string strTest = "Codes";
Response.Redirect("default2.aspx?jungPara="+strTest+"");
but client received address by get method so all of parameters can be displayed.
so i fix method to post.
<form method="post"
but i does't work by post.
hi
My english is a little.
anyway, nice to meet you~~
and give me your advice anytime~
|
|
|
|