SQL Statement Checkbox
Apr 16, 2004
Hi,
I have a dynamical query to select the data from my sql db.
Everything works fine except the checkboxes.
Since the values in the db table are stored in booleans (BIT) field and I am using the a string builder to generate the sql query, I am stucked.
How can I solve this problem?
My stringbuilder works roughly like:
string XRealtime = ckbReal.Checked.ToString();
XRealtime = (XRealtime !="False" ? "Main.Realtimedata = '" + XRealtime + "'": "");
System.Text.StringBuilder query = new System.Text.StringBuilder();
query.Append("SELECT * From Main Where");
...
query.Append(XRealtime);
query.Append((XRealtime !="" ? " AND " : ""));
...
Thank you in advance...
Gorginio
View 1 Replies
ADVERTISEMENT
Jul 24, 2006
hi I have a bit field in sql server represented by a checkbox ... I am updating the database in code ( ie not using formview generated update .. ) the line that is falling over is .Parameters.Add("@archive", SqlDbType.Bit).Value = txtarchive.Checkedit falls over saying failed to convert string parameter to boolean the
value of txtarchive.checked is either true or false - how do i convert
this to 1 or 0 or something that sql is happy with ... thanks
View 2 Replies
View Related
Mar 26, 2008
Hi AllgI have problem in using the SQLDataSource. When in VS 2005 I drag and drop the SQLDataSource onto my page and then add a GridView control.I bind the GridView control to the SQLDataSource control. But the problem is it does not generate the INSERT, UPDATE, and DELETE statements. The dialog box is inactive. The screenshots may help. please help me in this regard. I also tried it for Accesscontrol but the same problem. Sorry for my poor English!. thanks in advancehttp://img205.imagevenue.com/img.php?image=27550_1_122_203lo.JPGhttp://img139.a.com/img.php?image=28285_2_122_937lo.JPG
View 1 Replies
View Related
Jun 2, 2004
Hi,
Even this question is not related to this forum but may be some one help me.
I have a master detail form. I want to delete record but only those record that user click with checkbox. There is no field like boolean. How can I make a scenerio about adding an unbound checkbox in detail form and how would i link with rows in detail sub form.
any help will be highly appreciated.
Regards,
View 2 Replies
View Related
Feb 2, 2006
hello all i have a 2 questions hope that u can help me my first question is: in ms access there was a data type named yes/no and it was a checkbox is there a checkbox data type in sql server 2005?
my second question is i need the connection code between asp.net 2005 and sql server 2005 i searched in here for that code but i got more confuse i found two codes and both are not working so hope u can give me the right connecting code. that's all thanks
View 11 Replies
View Related
Feb 8, 2007
Hi all,
I'm using the NULL checkbox in a report. Is it possible to change the diplayed name 'NULL' in a different name. The user will not see 'NULL' but something else.
Is that possible??
Greetz
View 3 Replies
View Related
Jan 30, 2008
Hi All,
I have a database table with a bit field. In my .aspx page I have a checkbox that is checked by default. My SqlDataSource is set up like so:
InsertCommand="INSERT INTO Studies (Study_Name, Study_Status) VALUES (@StudyName, @StudyStatus)"> <InsertParameters> <asp:ControlParameter ControlID="txtStudyName" Name="StudyName" PropertyName="Text" Type="String"/> <asp:ControlParameter ControlID="chkboxStudyStatus" Name="StudyStatus" PropertyName="Text" Type="Boolean"/>
I'm getting an error when inserting.
Error: Cannot insert the value NULL into column 'Study_Status', table 'Studies'; column does not allow nulls. INSERT fails. The statement has been terminated.
View 2 Replies
View Related
Mar 7, 2008
Hello
I need to make a webpage that stores the name, email, ... from the user into a database. The user also checks several checkboxes to register for some items. That last one gives me some trouble. Inside my code the checkbox-value is stored into a Boolean (true of false). On the sql-server I declared my field as a Bit (0 or 1).
1 public string Input_inschrijving(cls_inschrijving nieuwe_inschrijving) {
2
3
4
5 inschrijving_cn = new SqlConnection("Data Source=serverIp;Persist Security Info=True;User ID=DBname;Password=mypasword");
6
7
8
9 string stUser = "INSERT INTO tbl_inschrijving (naam, voornaam, straat, nr, postcode, woonplaats, telefoon, email, functie, organisatie, ostraat, onr, opostcode, owoonplaats, otelefoon, oemail, ws1, ws2, ws3, ws4, ws5, ws6, ws7, ws8, ws9, ws10, ws11, ws12) VALUES ('" + m_naam + "', '" + m_voornaam + "', '" + m_straat + "', '" + m_nr + "', '" + m_postcode + "', '" + m_woonplaats + "', '" + m_telefoon + "', '" + m_email + "', '" + m_functie + "', '" + m_organisatie + "', '" + m_ostraat + "', '" + m_onr + "', '" + m_opostcode + "', '" + m_owoonplaats + "', '" + m_otelefoon + "', '" + m_oemail + "', " + m_ws1 + " , " + m_ws2 + " , " + m_ws3 + " , " + m_ws4 + " , " + m_ws5 + " , " + m_ws6 + " , " + m_ws7 + " , " + m_ws8 + " , " + m_ws9 + " , " + m_ws10 + " , " + m_ws11 + " , " + m_ws12 + ")";
10
11
12
13 cm = new SqlCommand(stUser, inschrijving_cn);
14
15
16
17 try
18
19 {
20
21 inschrijving_cn.Open();
22
23 dr = cm.ExecuteReader();
24
25 dr.Close();
26
27 inschrijving_cn.Close();
28
29 return "Your registration was succesfull!";
30
31
32
33 }
34
35 catch(SqlException sx) {
36
37 return "Error!" + sx.Message;
38
39 }
40
41 }
42
Inside the table tbl_inschrijving on the SQL-server, i declared the checkbox values ws1, ws2, ws3, ... to a bit with length 1 (nulls allowed)How can I store the boolean-value into my table? I tried to change several declarations (int, char, varchar...) nothing works.
View 3 Replies
View Related
Apr 29, 2008
<asp:CheckBox ID="chkName" Checked='<%#Bind("FirstName_Disp")%>' runat="server" />
<asp:SqlDataSource ID="srcProfile" runat="server" ConnectionString="<%$ ConnectionStrings:webConn %>" SelectCommand="sp_Profile_Get" SelectCommandType="StoredProcedure" DeleteCommand="sp_Profile_Delete" DeleteCommandType="StoredProcedure" UpdateCommand="sp_Profile_Update" UpdateCommandType="StoredProcedure"> <SelectParameters> <asp:SessionParameter Name="UserID" SessionField="NewUserID" /> </SelectParameters> <DeleteParameters> <asp:Parameter Name="UserID" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="UserID" /> ****
<asp:Parameter Name="Name_Disp" Type="Byte" />
****</UpdateParameters></asp:SqlDataSource>
ALTER PROCEDURE dbo.sp_Profile_Update
@UserID uniqueidentifier,
****
@Email_Disp tinyint
****
AS
UPDATE [tbl****]
SET ****
Email_Disp = @Email_Disp
****
WHERE UserID = CONVERT(uniqueidentifier,@UserID)
Above is a sample of a checkbox that users on my site can check/uncheck so that certain information will/will not display to other users. However, the only value that writes to the DB table--depending if it is checked or unchecked--is a 1 (checked). In a previous iteration of the page, it worked so I know it can be done but I didn't save the method. Any suggestions?
View 11 Replies
View Related
May 12, 2008
I have a form set-up and am trying to add multiple items in my checkbox to the database; however, the only thing added to the database is the first item checked. Here is the code and any help will be greatly appreciated. Thank you!:<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConConnectionString %>" InsertCommand="INSERT INTO Consultations(FullName, Email, Business, BusinessInfo, Services, Comments) VALUES (@FullName, @Email, @Business, @BusinessInfo, @Services, @Comments)"
SelectCommand="SELECT Consultations.* FROM Consultations">
<InsertParameters>
<asp:ControlParameter Name="FullName" Type="String" ControlId="fullname" PropertyName="Text" />
<asp:ControlParameter Name="Email" Type="String" ControlId="emailTextBox" PropertyName="Text" />
<asp:ControlParameter Name="Business" Type="String" ControlId="bisDropDownList" PropertyName="SelectedValue" />
<asp:ControlParameter Name="BusinessInfo" Type="String" ControlId="businessTextBox" PropertyName="Text" />
<asp:ControlParameter Name="Services" Type="String" ControlID="checkboxlist" PropertyName="SelectedValue" />
<asp:ControlParameter Name="Comments" Type="String" ControlID="commentsTextBox" PropertyName="Text" />
</InsertParameters>
</asp:SqlDataSource>
View 3 Replies
View Related
Dec 14, 2006
All,
When creating a dynamic parameter list from a query, Reporting Services graciously provides a "(Select All)" checkbox. How can I select this checkbox by default so that when a user generates the report, all of the values are selected?
Thanks
View 7 Replies
View Related
Aug 24, 2006
Hi there,
I am using SQL Server 2005 Reporting Services. Right now, I have a textbox with 0 or 1 values in my report and I want to show a checkbox: checked for value 1 and uncheck for 0. Is there anyway to add a checkbox in the report?
Thanks in advance.
semaj
View 5 Replies
View Related
Oct 18, 2007
Hi !
I have a problem,i have two reports in first report i shwo names of employers and in the second i show names of their employees and i've linked these reports with navigation but there is a problem becuse i want to show details of two or three rows together in second report,and i want to have check box for this,i need to use check box in preview mode in reporting services.How to have check box to select two or three employers ?
Thanks alot.
SHIARM
View 11 Replies
View Related
Jan 15, 2008
Hi,
I have a order form and i want to take it to the next level.. So i have a report in my reportserver is exceuted using a sproc. I am using an Report viewer to view the report in my web application.
So is it possible to have 2 - 3 check boxes that will populate thru the webapplication, in my report viewer and still use the report from the report server.. For eg.
The data in my report will looks like this
OrderNo PlanId PlanName ... ETc
chkbox 45 15 ABD
chkbox 46 75 BDA
any help will be appreciated.
Regards
Karen
View 4 Replies
View Related
Mar 19, 2008
Hi i am trying to store the checkbox values on my page to the database, but im stuck on what to do. I have the following code already;protected void Btn_Subscribe_Click(object sender, EventArgs e)
{SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["streamConnectionString"].ConnectionString);
string strSQL = "INSERT INTO Newsletter(emailAddress) VALUES (@emailAddress)";SqlCommand Command = new SqlCommand(strSQL, conn);
Command.Parameters.Add("@emailAddress", SqlDbType.VarChar);Command.Parameters["@emailAddress"].Value = txtEmail.Text;
conn.Open();
Command.ExecuteNonQuery();
conn.Close();
}
How do i now insert the values from my checkbox, this is how i am setting the checkbox;public void Page_Load(object sender, EventArgs e)
{ArrayList values;if(!IsPostBack)
{
//Build array of data to bind to checkboxlistvalues = new ArrayList();
values.Add("Sport");values.Add("Gardening");values.Add("technology");
AlertList.DataSource = values;
AlertList.DataBind();
}
If i am going about it the wrong way please let me know, thanks
View 15 Replies
View Related
May 21, 2008
The following checkbox in my FormView only records "True" to the database, even after the checkbox is unchecked. After exhausting searches for many weeks, I'm in desperate need of a resolution and would very much appreciate your expertise. From what I understand, the #Bind feature is supposed to be a 2-way binding but I don't know why it doesn't work with my checkbox controls. I know that I should use AutoPostBack="True", but when I do so, I get the error "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control."
<asp:UpdatePanel ID="udp1" UpdateMode="Conditional" runat="server"> <ContentTemplate> <asp:CheckBox ID="chkEmail" Text="Display?" TextAlign="left" Checked='<%#Bind("Email_Disp")%>' runat="server" /><br /> </ContentTemplate> </asp:UpdatePanel>
<asp:SqlDataSource ID="srcProfile" runat="server" ConnectionString="<%$ ConnectionStrings:webConn %>"
SelectCommand="sp_Profile_Get" SelectCommandType="StoredProcedure"
DeleteCommand="sp_Profile_Delete" DeleteCommandType="StoredProcedure"
UpdateCommand="sp_Profile_Update" UpdateCommandType="StoredProcedure">
<SelectParameters>
<asp:SessionParameter Name="UserID" SessionField="NewUserID" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="UserID" />
[snip]
<asp:Parameter Name="Email_Disp" Type="Boolean" />
[snip]
</UpdateParameters>
</asp:SqlDataSource>
---------From DB table: Email_Disp bit---------
ALTER PROCEDURE dbo.sp_Profile_Get
@UserID uniqueidentifierAS SELECT *
FROM [myTable] WHERE UserID = CONVERT(uniqueidentifier,@UserID)
---------
ALTER PROCEDURE dbo.sp_Profile_Update @UserID uniqueidentifier,[snip] @Email_Disp bit,[snip]
ASUPDATE [myTable] SET [snip], Email_Disp = @Email_Disp, [snip]WHERE UserID = CONVERT(uniqueidentifier,@UserID)
View 19 Replies
View Related
Aug 15, 2005
Hi there, I've tried googling this (and looking at the many questions on the forum :) but I've not managed to find a decent tutorial / guide that describes a method for using checkboxs to insert true/false flags in a MS SQL db. The db field i'm setting has type set to "bit", is this correct? And secondly (its been a long day!) I just cant figure out the code to assign the bit 1 or 0 / true or false. This is what I've got so far but it's not working........Function InsertProduct(ByVal prod_code As String, ByVal prod_name As String, ByVal prod_desc As String, ByVal prod_size As String, ByVal prod_price As String, ByVal prod_category As String, ByVal aspnet As Boolean) As Integer Dim connectionString As String = "server='server'; user id='sa'; password='msde'; Database='dbLD'" Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(connectionString) Dim queryString As String = "INSERT INTO [tbl_LdAllProduct] ([prod_code], [prod_name], [prod_desc], [prod_size], [prod_price], [prod_category],[aspnet]) VALUES (@prod_code, @prod_name, @prod_desc, @prod_size, @prod_price, @prod_category, @aspnet)" Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString, sqlConnection) sqlCommand.Parameters.Add("@prod_code", System.Data.SqlDbType.VarChar).Value = prod_code sqlCommand.Parameters.Add("@prod_name", System.Data.SqlDbType.VarChar).Value = prod_name sqlCommand.Parameters.Add("@prod_desc", System.Data.SqlDbType.VarChar).Value = prod_desc sqlCommand.Parameters.Add("@prod_size", System.Data.SqlDbType.VarChar).Value = prod_size sqlCommand.Parameters.Add("@prod_price", System.Data.SqlDbType.VarChar).Value = prod_price sqlCommand.Parameters.Add("@prod_category", System.Data.SqlDbType.VarChar).Value = prod_category If chkAspnet.Checked = True Then sqlCommand.Parameters.Add("@aspnet","1") Else sqlCommand.Parameters.Add("@aspnet","0") End If Dim rowsAffected As Integer = 0 sqlConnection.Open Try rowsAffected = sqlCommand.ExecuteNonQuery Finally sqlConnection.Close End Try Return rowsAffected End Function Sub SubmitBtn_Click(sender As Object, e As EventArgs) If Page.IsValid then InsertProduct(txtCode.Text, txtName.Text, txtDesc.Text, ddSize.SelectedItem.value, ddPrice.SelectedItem.value, ddCategory.SelectedItem.value, aspnet.value) Response.Redirect("ListAllProducts.aspx") End If End SubAny help would be appreciated or links to tutorials.ThanksBen
View 2 Replies
View Related
Mar 2, 2005
Am I correct in finding that there's no checkbox in SQL Server Reporting Services? What other way do you have to display a bit field other than 0-1 ??
View 1 Replies
View Related
Dec 13, 2007
it looks like a multi value parameter is the only kind of parameter that displays a checkbox.
A single checkbox for yes/no parameters are more intuitive to my users than 2 choices from a query.
I tried to set the multi value attribute on such a param but at run time get errors from a couple of places 1) expressions that reference such a parameter, seemingly confused about the value field being allowed to be either an object or an integer 2) unchecking the checkbox causes a prompt demanding that a value be set.
Does anybody have a trick or see what I am missing in trying to make a parameter act like a single yes/no checkbox in just one line of a dropdown parameter list?
View 3 Replies
View Related
Oct 30, 2007
Hello,
I have a report in which one parameter has with multiple selections (List of CheckBoxes). SSRS automatically adds a "Select All" value as the first option. I'm showing a User Type list, but for example, usually the user running the report will be selecting two or three sets of "User Types" (*), then I named those selections and put them in the list also. The list looks like:
"Select All"
IT Users (*)
HR Users (*)
Programmers
DB Analyst... etc...
What I'm trying to do is that when the user selects "IT Users" (per example), then the options "Programmers" and "DB Analyst" will be checked automatically, because they belong to "IT Users" group.
Any help will be appreciated... Thanks in advance
View 2 Replies
View Related
Feb 29, 2008
Hi,
Can anybody help me fetch "True" & "False" value from a CheckBox inside a DataGridView row.
I tried the following code:-
But the cell.Selected doesnot take the correct value.
objGrid = (System.Windows.Forms.DataGridView)controlObj[0];
foreach (DataGridViewRow row in objGrid.Rows)
{
DataGridViewCheckBoxCell cell = row.Cells[0] as DataGridViewCheckBoxCell;
if (cell.Value != cell.FalseValue)
{
if (cell.Selected == true)
{
///Some Code;
}
}
}
Kindly Help ASAP
Thanks
View 4 Replies
View Related
May 1, 2008
I am trying to insert into a database Checkbox list items, I get good values up till the checkBox List and then it gives me all O's, My fields in my database are bit columns so I need the checkbox list itmes to be converted to this format. This is what i have so far. One thing is I don;t think I am inserting into the correct database columns. bitLOD, bitInjury, bitIllness, bitreferral are the database fileds.Private Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
'Check for the page ID to make sure not an update page then either insert new data or update existing data.
Dim id As String
Dim LOD As Byte
Dim Injury As Byte
Dim Illness As Byte
Dim Referral As Byte
id = Trim(Request.QueryString("ID"))For Each LItems As ListItem In CheckBoxList1.Items
If LItems.Selected = True ThenSelect Case LItems.ValueCase "1"
LOD = 1Case "2"
Injury = 1Case "3"
Illness = 1Case "4"
Referral = 1
End Select
End If
Next
'Put data into the Database
If id = "" Then
'save data into the database
sql = "INSERT tblSADHealth (intTaskForceID, intUICID, strSSN, dtInjury, strNotes, LOD, Injury, Illness, Referral,) " _
& "VALUES (" & ddlTaskForce.SelectedValue & ", " & DDLUIC.SelectedValue & ", '" & txtSSN.Text & "', '" & txtStatus.Text & "', " _
& "'" & txtDate.Text & "','" & txtNotes.Text & "', " & LOD & ", " & Injury & ", " & Illness & ", " & Referral & ")"
Response.Write(sql)
Response.End()
View 4 Replies
View Related
Jun 4, 2008
Hi,
On my page I am using a wizard control with textboxes to collect data from the visitor.
When they click the finish button - this inserts their data into a Sql database.
On the form is a checkbox.
I dont know what type to use in the database column to accept this and also
how to configure the checkbox on the page so I know if its checked.
Also what would be inserted into the database column "yes" "no" or a numerical value??
Thanks for any advice?
amereto
View 1 Replies
View Related
Nov 26, 2003
Not sure if this is the place to post this, but here goes.
I need to setup an options screen where my customers can customize which locations will be stored for their user id when pulling reports. I have checkbox list that dynamically loads their locations. I need to store the selected checkbox items in my table and then each time they login in to run a report, it will use the stored Location values in my SQL query.
Synopsis:
Selected locations stored in table. When the report is ran, the location values are pulled and added to my queries WHERE clause.
Thanks.
View 1 Replies
View Related
Dec 17, 2004
Edited by SomeNewKid. Please post code between <code> and </code> tags.
This is probaly the easiest question you've ever read but here goes.
I have a simple checkbox value that i want to insert into the database but whatever i do it does not seem to let me.
Here is my code:
Sub AddSection_Click(Sender As Object, e As EventArgs)
Dim myCommand As SqlCommand
Dim insertCmd As String
' Build a SQL INSERT statement string for all the input-form
' field values.
insertCmd = "insert into Customers values (@SectionName, @SectionLink, @Title, @NewWindow, @LatestNews, @Partners, @Support);"
' Initialize the SqlCommand with the new SQL string.
myCommand = New SqlCommand(insertCmd, myConnection)
' Create new parameters for the SqlCommand object and
' initialize them to the input-form field values.
myCommand.Parameters.Add(New SqlParameter("@SectionName", SqlDbType.nVarChar, 50))
myCommand.Parameters("@SectionName").Value = Section_name.Value
myCommand.Parameters.Add(New SqlParameter("@SectionLink", SqlDbType.nVarChar, 80))
myCommand.Parameters("@SectionLink").Value = Section_link.Value
myCommand.Parameters.Add(New SqlParameter("@Title", SqlDbType.nVarChar, 50))
myCommand.Parameters("@Title").Value = Section_title.Value
If New_window.Checked = false Then
myCommand.Parameters.Add(New SqlParameter("@NewWindow", SqlDbType.bit, 1))
myCommand.Parameters("@NewWindow").Value = 0
else
myCommand.Parameters.Add(New SqlParameter("@NewWindow", SqlDbType.bit, 1))
myCommand.Parameters("@NewWindow").Value = 1
End If
If Latest_news.Checked = false Then
myCommand.Parameters.Add(New SqlParameter("@LatestNews", SqlDbType.bit, 1))
myCommand.Parameters("@LatestNews").Value = 0
else
myCommand.Parameters.Add(New SqlParameter("@LatestNews", SqlDbType.bit, 1))
myCommand.Parameters("@LatestNews").Value = 1
End If
If Partners.Checked = false Then
myCommand.Parameters.Add(New SqlParameter("@Partners", SqlDbType.bit, 1))
myCommand.Parameters("@Partners").Value = 0
else
myCommand.Parameters.Add(New SqlParameter("@Partners", SqlDbType.bit, 1))
myCommand.Parameters("@Partners").Value = 1
End If
If Support.Checked = false Then
myCommand.Parameters.Add(New SqlParameter("@Support", SqlDbType.bit, 1))
myCommand.Parameters("@Support").Value = 0
else
myCommand.Parameters.Add(New SqlParameter("@Support", SqlDbType.bit, 1))
myCommand.Parameters("@Support").Value = 1
End If
myCommand.Connection.Open()
' Test whether the new row can be added and display the
' appropriate message box to the user.
Try
myCommand.ExecuteNonQuery()
Message.InnerHtml = "Record Added<br>" & insertCmd
Catch ex As SqlException
If ex.Number = 2627 Then
Message.InnerHtml = "ERROR: A record already exists with " _
& "the same primary key"
Else
Message.InnerHtml = "ERROR: Could not add record, please " _
& "ensure the fields are correctly filled out"
Message.Style("color") = "red"
End If
End Try
myCommand.Connection.Close()
BindGrid()
End Sub
Any response would be appreciated
View 2 Replies
View Related
Apr 13, 2006
Dim strStatus As String
Dim strGroup As String
Dim strLicense As String = dtgPhysician.DataKeys(e.Item.ItemIndex)
Dim strUpdateStatus As String
Dim strUpdateGroup As String
Dim strName As String
Dim strDate As String
Dim strSubject As String
Dim blPDA As Boolean
Dim strPDA As Byte
strStatus = CType(e.Item.FindControl("lstStatus"), DropDownList).SelectedItem.Text
strGroup = CType(e.Item.FindControl("txtGroup"), TextBox).Text
strName = e.Item.Cells(1).Text.Trim
strDate = CType(e.Item.FindControl("txtDate"), TextBox).Text
strSubject = CType(e.Item.FindControl("dpTraining"), DropDownList).SelectedItem.Text
blPDA = CType(e.Item.FindControl("ckPDA"), CheckBox).Checked
strPDA = Convert.ToString(blPDA)
strUpdateStatus = "UPDATE DoctorMaster SET Status = @p_Status , PGroup=@p_Group , @p_PDA wHERE (PLIC= @p_License);"
' ... Make a SQL call to update the database ...
'UpdatePhysician
Dim strConn As String
strConn = ConfigurationSettings.AppSettings("ConString")
If strConn = String.Empty Then
myConn = New SqlConnection()
Else
myConn = New SqlConnection(strConn)
End If
myConn.Open()
Dim daPhysician As New SqlDataAdapter()
Dim comUpdate As New SqlCommand()
comUpdate.Connection = myConn
daPhysician.UpdateCommand = comUpdate
comUpdate.CommandType = CommandType.Text
comUpdate.CommandText = strUpdateStatus
'Return the DataGrid to its pre-editing state
comUpdate.Parameters.Add(New System.Data.SqlClient.SqlParameter("@p_Status", System.Data.SqlDbType.Char, 3, "Status")).Value = strStatus
comUpdate.Parameters.Add(New System.Data.SqlClient.SqlParameter("@p_Group", System.Data.SqlDbType.NVarChar, 15, "PGroup")).Value = strGroup
comUpdate.Parameters.Add(New System.Data.SqlClient.SqlParameter("@p_License", System.Data.SqlDbType.NVarChar, 15, "PLIC")).Value = strLicense
comUpdate.Parameters.Add(New System.Data.SqlClient.SqlParameter("@p_PDA", System.Data.SqlDbType.Bit, "PDA")).Value = CType(e.Item.FindControl("ckPDA"), CheckBox).Checked.ToString
comUpdate.ExecuteNonQuery()
comUpdate.Dispose()
Thanks.
It kept givimg me data format error.
View 1 Replies
View Related
Sep 16, 2015
How can we create a checkbox in SSRS and how can it be enabled disabled based on the value.
View 5 Replies
View Related
Mar 29, 2007
My parameter pass the id of the parameter to my query while its name is displyed on the parameter combo.
I have a report on which there is a text field.
1,On this field i want's to display the name of the parameter.
If select all check box is check i want's to show Report of AllFieldName.
other wise it should be comma separate like Report of aa,cc.
e.g
I have field myfield with fieldname aa,bb,cc dd value with fieldid as 1,2,3,4
I am passing this parameter in the query like
select ... where id in( @fieldid)
2,I am exporting this report in a excel format.
How can i pass the parameter in the query string ,submit it.
{How to check select all parameter or particular parameter e.t.c }
View 4 Replies
View Related
Feb 5, 2007
Hi,
I believe somebody know the reason. Please help me on it!
I plan to pass a multivalued parameter from my web application to the server report, and let user select the value(s) from the value set. But when I run the report, there's no checkbox leftside of the values, that means user has no choice on this parameter.
Is there any way to do it?
Thanks,
Jone
View 2 Replies
View Related
Dec 11, 2007
Hi,
I'm new to ASP.NET 2.0. I'll like to ask how do one save user input from txtbox, radiobttnlist or checkboxlist into database?
Im implementing a suvrey form here by the way.
-any reference webs,
-any pointers from experts?
Thank you for your time in reading this email
Kayln
View 7 Replies
View Related
Mar 26, 2008
I have problem in using the SQLDataSource. When in VS 2005 I drag and drop the SQLDataSource onto my page and then add a GridView control.I bind the GridView control to the SQLDataSource control. But the problem is it does not generate the INSERT, UPDATE, and DELETE statements. The dialog box is inactive. The screenshots may help. please help me in this regard. I also tried it for Accesscontrol but the same problem. Sorry for my poor English!. thanks in advance
the screenshot links:
http://img139.imagevenue.com/img.php?image=28285_2_122_937lo.JPGhttp://img205.imagevenue.com/img.php?image=27550_1_122_203lo.JPG
View 7 Replies
View Related
Sep 12, 2005
I have been trying to add values to a database and it keeps failing
i have no idea what i am doing wrong please help the code is asp.net
using vb. I have been having serious trouble passing check boxes in
forms from day one both singularly and dynamically from datagrids
if someone could show me some sample code of how to pass these
sort of values into the component and on to the query in this way
i would very much appreciate it.
Fuzzygoth
the error returned is
Description: An
unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the
error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException:
INSERT statement conflicted with COLUMN FOREIGN KEY constraint
'tblStation_FK00'. The conflict occurred in database 'TealSQL', table
'tblTravelPoint', column 'travelpointID'.
The statement has been terminated.
I have marked the area of the code the error is returned in the colour Violet and with a ##
The code i am using is below
## The aspx page ##
<%@ Page Language="vb" Debug="true" Trace="True"
Inherits="Devotion2Motion.AdminComp"
Src="../CodeBehind/AdminModule.vb" %>
<!-- Binds the ActivityResortInfo.ascx user control to the page -->
<%@ Register TagPrefix="UserContol" TagName="D2MHeader" Src="../UserControls/Header.ascx" %>
<%@ Register TagPrefix="UserContol" TagName="D2MFooter" Src="../UserControls/Footer.ascx" %>
<%@ Register TagPrefix="UserContol" TagName="TravelPointDD" Src="../UserControls/TravelPointDD.ascx" %>
<script language="vb" runat="server">
Sub Page_Load()
If IsPostback = True Then
Dim aInternational As Integer
Dim Station As String = Request.Form("StationFrm")
Dim Type As String = Request.Form("TypeFrm")
Dim Address1 As String = Request.Form("address1Frm")
Dim Address2 As String = Request.Form("address2Frm")
Dim City As String = Request.Form("cityFrm")
Dim International As String = Request.Form("InternationalFrm")
Dim TravelPoint As Integer = Request.Form("_ctl5:dsTravelPointDD")
If IsNothing(International) Then
aInternational = "0"
Else
aInternational = "1"
End If
Dim AdminTravelPoints As New Devotion2Motion.AdminComp()
' Select the country dropdown list
AdminTravelPoints.AddStation(Station, Type, Address1, Address2, City,
aInternational, TravelPoint)
End If
Dim ReadResultTable As New Devotion2Motion.AdminComp()
' Select the country dropdown list
dsResultSet.DataSource = ReadResultTable.GetStationtbl()
dsResultSet.DataBind()
End Sub
</script>
<!-- This UserControl Pulls in the header UserControl and the Div Tag Positions it #css reffrence is TopControl -->
<Div Class="TopControl">
<UserContol:D2MHeader runat="server"/>
</Div>
<form method="post" action="AdminTravelPoint.aspx" runat="server">
<Div Class="CentreControl">
<table border="0">
<tr>
<td>
<asp:Label Text="Station Name: " CssClass="BodyStyle" runat="server"/>
</td>
<td>
<asp:TextBox ID="StationFrm" CssClass="PrimaryGrid" runat="server"/>
</td>
<tr>
<tr>
<td>
<asp:Label Text="Type: " CssClass="BodyStyle" runat="server"/>
</td>
<td>
<asp:TextBox ID="TypeFrm" CssClass="PrimaryGrid" runat="server"/>
</td>
<tr>
<tr>
<td>
<asp:Label Text="Address1: " CssClass="BodyStyle" runat="server"/>
</td>
<td>
<asp:TextBox ID="Address1Frm" CssClass="PrimaryGrid" runat="server"/>
</td>
<tr>
<tr>
<td>
<asp:Label Text="Address2: " CssClass="BodyStyle" runat="server"/>
</td>
<td>
<asp:TextBox ID="Address2Frm" CssClass="PrimaryGrid" runat="server"/>
</td>
<tr>
<tr>
<td>
<asp:Label Text="City: " CssClass="BodyStyle" runat="server"/>
</td>
<td>
<asp:TextBox ID="CityFrm" CssClass="PrimaryGrid" runat="server"/>
</td>
<tr>
<tr>
<td>
<asp:Label Text="International: " CssClass="BodyStyle" runat="server"/>
</td>
<td>
<asp:CheckBox ID="InternationalFrm" CssClass="PrimaryGrid" runat="server"/>
</td>
<tr>
</tr>
<td>
<asp:Label Text="Travel Point: " CssClass="BodyStyle" runat="server"/>
</td>
<td>
<UserContol:TravelPointDD runat="server"/>
</td>
<tr>
</tr>
<td>
</td>
<td>
<input value="Submit" type="submit">
</td>
</tr>
</table>
</Div>
<asp:DataGrid ID="dsResultSet" AutoGenerateColumns="False" CssClass="PrimaryGrid" ShowHeader="true" runat="server">
<Columns>
<asp:BoundColumn DataField="StationID" ReadOnly="true" HeaderText="Station ID"/>
<asp:BoundColumn DataField="Station" ReadOnly="true" HeaderText="Station"/>
<asp:BoundColumn DataField="Type" ReadOnly="true" HeaderText="Type"/>
<asp:BoundColumn DataField="Address1" ReadOnly="true" HeaderText="Address"/>
<asp:BoundColumn DataField="Address2" ReadOnly="true" HeaderText=" "/>
<asp:BoundColumn DataField="City" ReadOnly="true" HeaderText="City"/>
<asp:BoundColumn DataField="International" ReadOnly="true" HeaderText="International"/>
<asp:BoundColumn DataField="TravelPoint" ReadOnly="true" HeaderText="City"/>
</Columns>
</asp:DataGrid>
</form>
<Div Class="CenterControl">
<UserContol:D2MFooter runat="server"/>
</Div>
##the vb componet that passess to the sql query ##
Public Function AddStation(ByVal Station As String, ByVal Type As
String, ByVal Address1 As String, ByVal Address2 As String, ByVal City
As String, ByVal aInternational As Integer, ByVal TravelPoint As
Integer) As SqlDataReader
' Create Instance of Connection and Command Object
Dim
myConnection As New
SqlConnection(ConfigurationSettings.AppSettings("strConn"))
Dim
myCommand As New SqlCommand("sp_call_Station_Insert", myConnection)
' Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure
' Add Parameters to SPROC
Dim
parameterStation As New SqlParameter("@Station", SqlDbType.NVarChar, 50)
parameterStation.Value = Station
myCommand.Parameters.Add(parameterStation)
' Add Parameters to SPROC
Dim
parameterType As New SqlParameter("@Type", SqlDbType.NVarChar, 50)
parameterType.Value = Type
myCommand.Parameters.Add(parameterType)
' Add Parameters to SPROC
Dim
parameterAddress1 As New SqlParameter("@Address1", SqlDbType.NVarChar,
50)
parameterAddress1.Value = Address1
myCommand.Parameters.Add(parameterAddress1)
' Add Parameters to SPROC
Dim
parameterAddress2 As New SqlParameter("@Address2", SqlDbType.NVarChar,
50)
parameterAddress2.Value = Address2
myCommand.Parameters.Add(parameterAddress2)
' Add Parameters to SPROC
Dim
parameterCity As New SqlParameter("@City", SqlDbType.NVarChar, 50)
parameterCity.Value = City
myCommand.Parameters.Add(parameterCity)
' Add Parameters to SPROC
Dim
parameteraInternational As New SqlParameter("@aInternational",
SqlDbType.Int, 4)
parameteraInternational.Value = aInternational
myCommand.Parameters.Add(parameteraInternational)
' Add Parameters to SPROC
Dim
parameterTravelPoint As New SqlParameter("@TravelPoint", SqlDbType.Int,
4)
parameterTravelPoint.Value = TravelPoint
myCommand.Parameters.Add(parameterTravelPoint)
' Execute the command
myConnection.Open()
## Dim result As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
' Return the datareader
Return result
End Function
## The sql stored procedure ##
CREATE PROCEDURE [dbo].[sp_call_Station_Insert]
(
@Station As nVarChar(50),
@Type As nVarChar(50),
@address1 As nVarChar(50),
@address2 As nVarChar(50),
@City As nVarChar(50),
@aInternational As nVarChar(50),
@TravelPoint As Int
)
AS
DECLARE @ConVale As nVarChar(50)
SET @ConVale = (SELECT Station FROM tblStation WHERE @Station = Station)
If @ConVale = @Station
BEGIN
SELECT * FROM tblStation
END
ELSE
BEGIN
insert into tblStation
(Station, Type, address1, address2, city, International, TravelPoint)
values (@Station, @Type, @address1, @address2, @City, @aInternational, @TravelPoint)
SELECT * FROM tblStation
END
GO
View 1 Replies
View Related
Nov 15, 2013
I have a dropdown list with checkbox and when I select multiple options and search, its returning only the last selected value in the grid. Here is the code I use it for search. Designation is the column where I bind its values to the checkbox.
Checkbox tag:
<asp:CheckBoxList ID="cblGroup" Style="vertical-align: baseline" runat="server" CssClass="chkbox">
</asp:CheckBoxList>
Select Query:SqlCommand cmd = new SqlCommand("select * from AppInvent_Test where Designation= '" + cblGroup.SelectedValue + "'", con);
View 2 Replies
View Related