|
hi guys
i have a string
like "12007" or "112007"
in this string last four characters denotes to a specific year and the rest shows month ,
i want to get a the month either ir is 1 or 12 or 10 ,, i cannot use sunstring because i am not sure about its lenth it might me 1 or two , so how could i get the exazct month ,,,
thansk in advance
hello
|
|
|
|
|
Unless someone sticks the day of the month in there, then you got some trouble.
You have to assume that the last four are the year, then anything before that is going to be the month. Assuming the day of month isn't going to be there, you will have to check the length of the string. If it is 5 then you have one digit for the month, else if the length is 6, then you have two digits for the month. Find the length of the string first, then you can use SubString(....) to pick it apart.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
Why not look at the total length of the string then subtract 4 (the number of digits for the year portion) and use that data to know the rest?
Its just working backwards.
|
|
|
|
|
chop last 4 chars and parse, I would say.
|
|
|
|
|
Can someone please help me filling a DataGrid without a DataSource. I'm used to work with a component called the True DBGrid made by ComponentOne for VB6, and it was a walk in the park to change the cells' value. Surely there's a way to modify the values without a source, right?
Thanks in advance!
|
|
|
|
|
I Don't know if I understand your question correcly, but if you are using VS2005, and a DataGridView control, you can do this:
'Drop the control on your form
'Add two columns
Me.DataGridView1.Columns.Add("Col1", "FirstColName")
Me.DataGridView1.Columns.Add("Col2", "SecondColName")
'Add some rows - 5 in this case
Me.DataGridView1.Rows.Add(5)
'Modify the Data in the control
Me.DataGridView1.Item(0, 0).Value = "Hello" 'Row 0, Column 0
Me.DataGridView1.Item(0, 1).Value = "Dude" 'Row 1, Column 0
|
|
|
|
|
You could do how Richard described, but if you're going to save the data in the grdi, you'd be better off binding the grid to a DataTable you create. The DataTable object can save, and load, the data into/from an XML file without a pile of code on your part.
|
|
|
|
|
Hi, would you please explain the two lines of code below that are high lighted.
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(qry, con);
da.Fill(ds);
ListBox1.DataSource = ds;
ListBox1.DataValueField = "SingerID";
ListBox1.DataTextField = "Singer";
ListBox1.DataBind();
Are "SingerID" and "Singer" the names of fields in a database. The comment to the right of "Singer"; says that the name of singers will be displayed. How will it be displayed, in grid or something else? Thanks for your help.
|
|
|
|
|
SingerID is the id (probably primary key) of the Singer, and Singer contains the text of the name. What happens is if the user selects a name from the listbox, then the SelectedValue property of the listbox is the corresponding SingerID for that particular name.
"I've seen more information on a frickin' sticky note!" - Dave Kreskowiak
|
|
|
|
|
Suppose instead of having Singer and SingerID as the names of the fields in the database, I have ResumeID and Resumes as the names, and Resumes contains resumes of different people. Can I use the same technique that was used to display the content Singer to display the content of Resumes if Resumes is of type nvarchar or text? Thanks for responding.
-- modified at 22:32 Monday 23rd July, 2007
|
|
|
|
|
Singer looks as if it is the field in the database holding the names of the singers. In your case, you can change SingerID to ResumeID , and Singer to Resumes . It should work.
"I've seen more information on a frickin' sticky note!" - Dave Kreskowiak
|
|
|
|
|
Hi, please help I've been wrestling with this for a very long time and its not working. The following is my code.
<br />
<br />
Private Sub ListBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox2.SelectedIndexChanged<br />
<br />
Dim myCon As OdbcConnection<br />
Dim i As Integer<br />
Dim cmd As OdbcCommand<br />
For i = 0 To ListBox2.Items.Count - 1<br />
If ListBox2.Items(i).Selected Then<br />
<br />
myCon = New OdbcConnection("Driver={MySQL ODBC 3.51 Driver};Server=myServer;Database=myDatabase;User=myUserassword=myPass;Option=3;")<br />
cmd = New OdbcCommand("SELECT * FROM myTable where Professions = '" & ListBox2.Items(i).Text & "'")<br />
<br />
End If<br />
Next<br />
If Not IsNothing(myCon) Then<br />
myCon.Open()<br />
<br />
cmd.Connection = myCon<br />
<br />
Dim ds As New DataSet<br />
<br />
Dim ad As New OdbcDataAdapter(cmd)<br />
<br />
ad.Fill(ds)<br />
<br />
Me.ListBox2.DataSource = ds<br />
<br />
Me.ListBox2.DataTextField = "ResumesID"<br />
Me.ListBox2.DataTextField = "Resumes"<br />
Me.ListBox2.DataBind()<br />
<br />
End If<br />
End Sub<br />
|
|
|
|
|
ASPnoob wrote: User=myUserassword=myPass;
This might be your problem. Please describe the error you are having.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
ASPnoob wrote: Me.ListBox2.DataTextField = "ResumesID"
Me.ListBox2.DataTextField = "Resumes"
For starters you're setting the DataTextField 2 times. Once should be DataTextField (Resumes) and the other should be DataValueField (ResumeID)
"It's only that urgent if you have to pee."
Dave Kreskowiak
|
|
|
|
|
Psycho-*Coder*-Extreme wrote: For starters you're setting the DataTextField 2 times
Oops, how did I miss that one?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
Paul Conrad wrote: Oops, how did I miss that one?
Not enough coffee?
"Well yes, it is an Integer, but it's a metrosexual Integer. For all we know, under all that hair gel it could be a Boolean."
Tom Welch
|
|
|
|
|
Yeah, Dr. Pepper's wearing out here
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
Well you could always hook yourself up to a Dr. Pepper IV, then install a serial port to the back of your head, then even when you sleep you can answer questions here on CP
"Well yes, it is an Integer, but it's a metrosexual Integer. For all we know, under all that hair gel it could be a Boolean."
Tom Welch
|
|
|
|
|
Psycho-*Coder*-Extreme wrote: hook yourself up to a Dr. Pepper IV, then install a serial port to the back of your head, then even when you sleep you can answer questions here on CP
That would be cool, kind of like The Matrix sort of thing
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
The truly scary part is I actually think of things like that, how to find a way to install a serial port onto the back of my head and stuff, does that make me weird?
"Well yes, it is an Integer, but it's a metrosexual Integer. For all we know, under all that hair gel it could be a Boolean."
Tom Welch
|
|
|
|
|
Psycho-*Coder*-Extreme wrote: does that make me weird?
Nah, I've thought of how cool it would be to make a world like a Star wars world or Matrix kind of thing.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
Hi, please help I've been wrestling with this for a very long time and its not working. The problem is it doesn't generate any errors, no exception was thrown. The following is my code.
<br />
<br />
Private Sub ListBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox2.SelectedIndexChanged<br />
<br />
Dim myCon As OdbcConnection<br />
Dim i As Integer<br />
Dim cmd As OdbcCommand<br />
For i = 0 To ListBox2.Items.Count - 1<br />
If ListBox2.Items(i).Selected Then<br />
<br />
myCon = New OdbcConnection("Driver={MySQL ODBC 3.51 Driver};Server=myServer;Database=myDatabase;User=myUserassword=myPass;Option=3;")<br />
cmd = New OdbcCommand("SELECT * FROM myTable where Professions = '" & ListBox2.Items(i).Text & "'")<br />
<br />
End If<br />
Next<br />
If Not IsNothing(myCon) Then<br />
myCon.Open()<br />
<br />
cmd.Connection = myCon<br />
<br />
Dim ds As New DataSet<br />
<br />
Dim ad As New OdbcDataAdapter(cmd)<br />
<br />
ad.Fill(ds)<br />
<br />
Me.ListBox2.DataSource = ds<br />
<br />
Me.ListBox2.DataTextField = "ResumesID"<br />
Me.ListBox2.DataTextField = "Resumes"<br />
Me.ListBox2.DataBind()<br />
<br />
End If<br />
End Sub<br />
|
|
|
|
|
ASPnoob wrote: its not working. The problem is it doesn't generate any errors, no exception was thrown.
What is it doing wrong? I noticed the User in the connection string is questionable with the password...
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
What I wanted to do was to retrieve resumes which have been stored as text, from the database. Each resume has a corresponding profession which is stored in the Professions field and ResumesID is used as the primary key. I have created a listbox which has the names of different professions. When someone selects one or more professions from the listbox, resumes that correspond to the professions will be displayed. I have used the for loop for the multiple selection of the list items. Then I used the If statement to make sure that a list item is selected. The Select statement is suppose to pick the professions where the name of the professions match the text value of the selected list items. The problem is nothing happens when I select the list item.
-- modified at 0:45 Tuesday 24th July, 2007
|
|
|
|
|
What I would do is keep the listbox having the names of the different professions, then when the user selects the profession, a new listbox pops up with the resumes of the corresponding profession.
I think if you want to stick with the same listbox control, you have to also clear out the professions before binding the resumes. I stick to just having a new form open when the user selects something off a listbox or combobox.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|