|
And anyway, just because a field is null, it doesn't mean that you can assume that it is part of a key.
|
|
|
|
|
|
Its a JavaScript menus... You can do wonders using JavaScript...
|
|
|
|
|
Looks like a div with a table inside it - nothing too spectacular there
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
InvalidCastException
Conversion from string "A10001" to type integer is not valid
I have a query that returns a dataset from a database table. The field i am using as the criteria for fetching the data is of type Text(or Char).
Whenever i passed a value like "110000" there is no problem. But when i passed a value like "B235KK", THE ERROR ABOVE comes up.
pls help
t.aransiola
|
|
|
|
|
Could you post that code?
|
|
|
|
|
I will post that of the dataset later, but also i have this code as well reporting teh same error
Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load
Dim strClientID As String = CType(Session.Item("ClientID"), String) '"00144"
Dim strFormula As String = "{Client.ClientID}='" & strClientID & "'"
CrystalReportViewer1.SelectionFormula = strFormula
Sub
t.aransiola
|
|
|
|
|
ok. this is the second one.
'A class module
'
Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Data.OleDb
Public Class clGlobal
Dim strConn As String = "Provider=Microsoft.Jet.oledb.4.0;Data Source=C:\WebReports\db1.mdb"
Dim oConn As OleDbConnection
Dim oCmd As OleDbCommand = New OleDbCommand
Public Function ValidCustomer(ByVal CustCode As String, ByVal PinID As String) As Boolean
Dim intCount As Integer = 0
Dim strSQL As String = "Select ClientID,CPassword From Client Where "
strSQL &= "ClientID='" & CustCode.Trim & "'"
strSQL &= " AND CPassword='" & PinID.Trim & "'"
oConn = New OleDbConnection
oConn.ConnectionString = strConn
oConn.Open()
With oCmd
.CommandText = strSQL
.Connection = oConn
intCount = .ExecuteScalar
End With
ValidCustomer = False
If intCount > 0 Then
ValidCustomer = True
End If
oConn.Close()
End Function
End Class
t.aransiola
|
|
|
|
|
The Code seems ok... It seems that the ClientID must be of a Numberic Data Type in the Database... Please check the data type of the ClientID.
|
|
|
|
|
Thanks. Ive checked the ClientID in the database. The datatype is ok. And this is the datatype(i.e TEXT) i want to use. What i will do next is to use SQL Server database to see the effect.
I think this is a bug in the .net framework.
t.aransiola
|
|
|
|
|
aransiola wrote: Dim intCount As Integer = 0
Dim strSQL As String = "Select ClientID,CPassword From Client Where "
strSQL &= "ClientID='" & CustCode.Trim & "'"
strSQL &= " AND CPassword='" & PinID.Trim & "'"
oConn = New OleDbConnection
oConn.ConnectionString = strConn
oConn.Open()
With oCmd
.CommandText = strSQL
.Connection = oConn
intCount = .ExecuteScalar
End With
ValidCustomer = False
If intCount > 0 Then
ValidCustomer = True
End If
oConn.Close()
Hey Aran,
ExecuteScalar returns a single scalar value. But your query seems to select ClientID and CPassword. That is not possible in ExecuteScalar. Use Count(ClientID) in the SELECT query.
Your query should be,
Dim strSQL As String = "Select COUNT(ClientID) From Client Where "
strSQL &= "ClientID='" & CustCode.Trim & "'"
strSQL &= " AND CPassword='" & PinID.Trim & "'"
|
|
|
|
|
It's because the string doesn't represent an integer - I'm guessing it's hex? Int.Parse won't convert it for you.
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
Hi
I feel one of the Database table column is of type int and you are searching it with varchar type.
Check once the DBColumn Type.
|
|
|
|
|
thanks,
The table column and their type is of type Text. I have checked those areas, the table fields are ok.
I think this problem if from the .net framework. you can search google fo
"Input string not in the correct format"
t.aransiola
|
|
|
|
|
Hi all,
I have GridView which has 7 columns and 2 of them are BoundField columns and others are Template Columns which has Checkbox in it.
Now my problem is that I need to Bind the GridView depending upon the DataBase fields and check or uncheck the checkbox that is if Database has 1 then checkbox should be checked and if 0 then it shouldnt.
Also I need to Update the Database if the checkbox is value is changed.
Please tell me how do I go about this as I am have to do this in ASP.NET 2005 Version.
Thanks in advance..
|
|
|
|
|
you can use code something like
this for finding out what checkbox is checked or unchecked to update the database .based on position u can check checkbox value
<br />
For i As Int16 = 0 To DataGrid1.Items.Count - 1<br />
If CType(DataGrid1.Items(i).Cells(0).Controls(1), CheckBox).Checked Then<br />
<br />
Dim cmd As New SqlCommand("update abctable set changed='abc' where id=" & Val(DataGrid1.Items(i).Cells(1).Text)) <br />
cmd.Connection = conn<br />
conn.Open()<br />
cmd.ExecuteNonQuery()<br />
conn.Close()<br />
End If<br />
Next<br />
<br />
hope this might help you
enjoy..
|
|
|
|
|
thanks sir.but I want that there are number of rows and in each row there are 5 checkbox which may be checked or unchecked depending upon user.Once user finish this he will click Save button which is outside the GridView and all the rows must get save to Database.
for eg:
row 1: 1 checked checked checked checked unchecked
row 2: 2 unchecked checked unchecked checked unchecked
then when user clicks save button the values should go in the database as
1 1 1 1 1 0
2 0 1 0 1 0
where 1 and 2 are the ID of the table.
Please help me...Thanks...
|
|
|
|
|
Hey Varsha,
There is no need to make it as a Template Column if that field is of data type bit/boolean. You can use ordinary bound column... ASP.NET automatically creates a checkbox for that column.
Else,
Try this,
HTML,
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField HeaderText="Logged On">
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" Checked="<%# GetValue(Container.DataItem) %>"/>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="user_name" HeaderText="Username" />
</Columns>
</asp:GridView>
CodeBehind,
Protected Function GetValue(ByVal DataItem As Object) As Boolean
If DataBinder.Eval(DataItem, "logged_on") = "1" Then
Return True
Else
Return False
End If
End Function
Have a great day
|
|
|
|
|
Hi,
I want multiple checkbox in single row,so tell me how do I go about it?
Thanks...
|
|
|
|
|
Add the multiple checkboxes and bound my function with the field name...
|
|
|
|
|
Then how will I update the DataBase or Bind GridView when some of the fields are already there in DataBase???
Thanks...
|
|
|
|
|
Use
FindControl(CONTROLNAME) to get the checkboxes...
FindControl method is available in all the Rows of the GridView. Use SelectedRow to get the current selected row...
|
|
|
|
|
Here is the code:
<code><asp:GridView ID="GridView1" runat="server" DataSourceID="oDS1" AutoGenerateColumns="False" AllowPaging="True" AllowSorting="True" PageSize="15">
<Columns>
<asp:BoundField DataField="FormID" HeaderText="FormID"
InsertVisible="False" ReadOnly="True" SortExpression="FormID">
<HeaderStyle Width="50px" />
</asp:BoundField>
<asp:TemplateField HeaderText="CheckBox1" SortExpression="cb1data">
<ItemTemplate>
<asp:CheckBox ID="CB1" runat="server" Checked='<%# IsActive(Eval("cb1data")) %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CheckBox2" SortExpression="cb2data">
<ItemTemplate>
<asp:CheckBox ID="CB2" runat="server" Checked='<%# IsActive(Eval("cb2data")) %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CheckBox3" SortExpression="cb3data">
<ItemTemplate>
<asp:CheckBox ID="CB3" runat="server" Checked='<%# IsActive(Eval("cb3data")) %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</code>
The IsActive Class (returns a Boolean to represent the string value of "Yes"/"No" in the checkbox)
Public Shared Function IsActive(ByVal sValue As String) As Boolean
If sValue = "1" Then
Return True
Else
Return False
End If
End Function
The SaveButton Class (the values of the name and 3 checkboxes are captured in a label)
Protected Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim index As Integer
Dim sCB1Value As String = String.Empty
Dim sCB2Value As String = String.Empty
Dim sCB3Value As String = String.Empty
For index = 0 To GridView1.Rows.Count - 1
Dim gvRow As GridViewRow = GridView1.Rows(index)
If CType(gvRow.FindControl("CB1"), CheckBox).Checked Then
sCB1Value = "1"
Else
sCB1Value = "0"
End If
If CType(gvRow.FindControl("CB2"), CheckBox).Checked Then
sCB2Value = "1"
Else
sCB2Value = "0"
End If
If CType(gvRow.FindControl("CB3"), CheckBox).Checked Then
sCB3Value = "1"
Else
sCB3Value = "0"
End If
Next
End Sub
My Problem is that how do I insert or Update Database or what u suggested me not to use asp checkbox.
What changes should I make in the code to work properly.
Thanks....
|
|
|
|
|
Hi,
In my application,there are two textboxes where the user enters two dates.
I have tp print all the dates between these two entered dates by the user.Can anybody help?
|
|
|
|
|
The pseudo logic for this would look like:
set currentdate = first date + 1 day
while currentdate is less than second date
print currentdate
currentdate = currentdate + 1 day
end while
BTW - this looks suspiciously like a homework question.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|