M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !

i am new in c# , i have images in my mssql table and i want to show those images in the datagridview , i add a column type image , but i am not able to show images in it , please help me in this .

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

well , if you just want to show the value in textbox related to the selected value of the combo then you can do like this ,

dim con as new sqlconnection("your connection string ")
con.open()
dim da as new sqldataadapter("select val1 , val2 from table ",con)
dim dt as new datatable
da.fill(dt)
combobox1.datasource = dt
combobox1.displaymember = "val1"
combobox1.valuemember = "val2"
con.close()

now this code will get the records from the db , use this code at the selected index change event of the combo box.

textbox1.text = combobox1.selectedvalue.tostring

the val2 will be display in the textbox.
as i am typed all this code right here so may be there is some spelling mistake , please check it by your own self ,

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

any one help me in this , :(

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

agree wih you jim ,

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

thanks both of you , but prob is same , but thanks for your valuable time , :)

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

adam_k i cant get your poin , please can you explain it.

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

please change this line like this

for a = 0 to datagridview1.columns.count -1

hope this will solve your prob :)

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

can youplease be more specific that in which format i mean in excel or word or pdf etc ?

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

well you can first get the id or name of those frames , as i just worked once in a facebook scraper , so i dont have that much knowledge , but the basic idea is that you can use the get element by id , to get the any component of the web form by using its id , you can even change the inner html text to disable all othere part of the web page . here is a link hope this will help you to step forword.Click Here

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello all !
may God Bless you all , basically i like to work in .net , but due my boss's requirement i have to work on ExtJs , in the bigging it was very difficult for me to switch my self from .net to JS , but i am not working in it slow but smoothly , i search soooooo many sites , blogs , no one is able to help you in a real way in extjs , even the official forum of sencha , there is no one who can answer your prob. dani web is very good in this , you can get solutions almost of every programming language ,
there are so many people out there those are always looking for some good and fast forums where they can find solutions of there prob.
i just requesting on the behalf of all others that please add ExtJs to this site , so that people like me can able to improve there working.
in last sorry for my bad english .:)

Best Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
may God bless all of you, i m good in mssql , but this is very first time that i am very confuse , the case is , i have a table , having fields
1- ContactPersonId
2- Name
and 2nd table having fields
1- recId
2- ContactPersonId
3- PhoneNo
now i want to show all this information in my grid like in this way
abc ----- this is name
123 ----- this is number
456 ----- this is number
4785----- this is number
xyz----- this is name
145----- this is number
658----- this is number
mno----- this is name
852----- this is number
963----- this is number
please some one help me in this , or if you dont know how to do this then please share your ideas that how you think it can be done.

Best Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

well , there is an idea to deal with this situation , is that , you can just add a column to your db , name isViewing datatype bit , now if user one get records it will not only get records to you but also update isViewing true , and you can just add simple line to your query where isViewing = false ,
this is just an idea , please no hard feelings if you think i am wrong , :)

Best Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

well you can do like this , as in my computer there is no mssql installed so may be this will not work properly but give you an idea.

 select distinct fname ,'','' from table
      union all 
 select distinct '',mname,'' from table
  union all 
 select distinct '','',lname from table

this is just an idea try it . may be this will solve your prob :)

Best Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

i think you can do like this, now here is sample you can do same with your close function ,

Public Function Open_DB_Connection(byval formName as string) As String
        Try
            Connection.ConnectionString = "Data Source = LocalHost\;Initial Catalog = Database;Integrated Security  = True"
            Connection.Open()
            Return "Success"
        Catch ex As Exception
            MsgBox("your " & formName & " has Connection Error: " + ex.Message)
            Return "Fail"
            Exit Function
        End Try
    End Function

now you can easily call this function like this .

Open_DB_Con = Open_DB_Connection("your from name")

hope this will solve your prob :)

best Regards

Muhammad Waqas Aslam

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

i think there is nothing wrong with the query , as there is not that much time to read your full code , but i think you are using data table or data set , , the best way is to add row to your datagrid manualy using sqldatareader , this will not disturb your grid and simply add new rows to your grid.

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

my advice to beginner20 is that please try to study first , then search some code samples , after knowing all the basic logics and working of components which will be used in your coding then start coding , this will save lot of time of yours , while coding , this will also helps you to improve your self and also to code much complex programs, in this case your have to deal with 4 or five things ,
1- check box and buttons
2- grid
3- sql connection , sqldataadapter or sqldatareader , sqlcommand object , datatable
4- queries
5- simple logics how to get data from db then how to pass it your grid.

if you just spend one or two hours on them , belive me next time you will be here not to ask some thing about all these but to help others .

Best Regards

Muhammad Waqas Aslam

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

as i understand is that you have 10 rows and you have a column name house and a optimum value
now you just want to get the largest optimum value of any house ? if i m right then you can do like this.

here is code if there is single column of optimum value in your grid.

    dim maxVal as integer
     maxVal = 0 ;
     for i = 0 to datagridview1.rows.count -1 
        if maxVal < datagridview1.item(2,i).value.tostring then
        maxVal = datagridview1.item(2,i).value.tostring
        end if
     next
    msgbox ("your string here" & maxVal & " your string here.")

here is code if there is more then one column in the grid of optimum value ,

  dim maxVal as integer
     maxVal = 0 ;
     for i = 0 to datagridview1.rows.count -1 
         for a = 0 to datagridview1.column.count -1 
           if maxVal < datagridview1.item(a,i).value.tostring then
              maxVal = datagridview1.item(a,i).value.tostring
           end if    
         next
    next
    msgbox ("your string here" & maxVal & " your string here.")

as i typed all this code here so may be there is some mistake in it , so please if you find any do tell me here so that i can solve it , one more thing , please always post question with full description, so that you can get good an fast help and also post attachment if possible.

Best Regards

Muhammad Waqas Aslam

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
well there is not enough time to read your all code , it is better to always ask question to the point , as far as i understand you simply populate the grid from your database using vb.net , if yes then do like this .

import system.data
import system.data.sqlclient

'then just do this at the button click event
dim con as new sqlconnection("your Connection string here")
dim dt as new datatable
con.open()
dim da as new sqldataadapter("select * from table",con)
da.fill(dt)
datagridview1.datasource = dt
con.close()

this is simple code to populate your grid using vb.net , as i typed this code here so there may be some errors or spelling mistakes , so sorry in advance , and one more thing , DO NOT POST SINGLE QUESTION TWISE.

Regards

Muhammad Waqas Aslam

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
i am working on a simple grid , i create 3 columns name , A B C , manually , now i have a table having three fields A B C , i want to show Rec A in A col , B in B Col and C in C Col. but when i give datasource to my grid , it shows 6 columns , please guid me iin this .

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

i think the most simple way is this that when you make setup of your application to deploy it on your client machine , the window where you add all your files present in bin folder , and create shortcut at the desktop , there are two columns , you just right click on the left column , and a pop up window will open , just select startup folder and click it , then startup folder option will add into your left column , now select it and right click on the right column and select add shortcut and select the exe file same as you done before in desktop folder case , THAT's IT
now just simple install your application in any computer , your application will automaticaly add a shortcut to your startup folder , and will run when ever computer is starts .

Sorry for my bad english ,

Best Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello every one , !
i have same prob as the user had in this thread Click Here
first i thought to post my question in that thread but then i thought it is better to open new thread . in above mentioned thread a user have prob to connect server through internet , but i want to connect my server with my another pc connecting with a cross cable , i done all the things . but it is not connecting , i tried to google it and find videos , tutorials , blogs about this , but not working at my end , please guid me step by step so that i can solve my prob.

Best Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello every one !
i want to make an application that can work like windows remorte desktop connection or teamviewer , but on local network , how can i do this , i even dont know where to start my work , please guide me , and help me if you can .

Best Regards

MWAM

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

well , this is very simpele , you can do like this

dim con as new sqlconnection("your connection string")
con.open()
dim da as new sqldataadapter("select columnName from table",con)
dim dt as new datatable()
da.fill(dt)
combobox1.datasource = dt 
combobox1.displaymember = "columnName"
combobox1.valuemember = "ColumnName"
con.Close()

hope this will help you.

Best regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

dim i as integer
Dim conn As New SqlConnection("*******")
conn.open()
for i = 0 to DataGridView1.rows.count - 1
Dim query As String = "Insert Into orders(Itemname, Quantity, totalcost, barcode, ordernumber, orderdate, buyinprice, saleprice, vendorname, status, RepairNumber) values (@Itemname, @Quantity, @totalcost, @barcode, @ordernumber, @orderdate, @buyinprice, @saleprice, @vendorname, @status, @RepairNumber)"
Dim cmd As New SqlCommand(query, conn)
cmd.Parameters.AddWithValue("@itemname", DataGridView1.item(0,i).value.tostring)
cmd.Parameters.AddWithValue("@Quantity", DataGridView1.item(1,i).value.tostring)
cmd.Parameters.AddWithValue("@totalcost", DataGridView1.item(2,i).value.tostring)
cmd.Parameters.AddWithValue("@barcode", DataGridView1.item(3,i).value.tostring)
cmd.Parameters.AddWithValue("@ordernumber", DataGridView1.item(4,i).value.tostring)
cmd.Parameters.AddWithValue("@orderdate", DataGridView1.item(5,i).value.tostring)
cmd.Parameters.AddWithValue("@buyinprice", DataGridView1.item(6,i).value.tostring)
cmd.Parameters.AddWithValue("@saleprice", DataGridView1.item(7,i).value.tostring)
cmd.Parameters.AddWithValue("@vendorname", DataGridView1.item(8,i).value.tostring)
cmd.Parameters.AddWithValue("@status", DataGridView1.item(9,i).value.tostring)
cmd.Parameters.AddWithValue("@repairnumber", DataGridView1.item(10,i).value.tostring)
cmd.executenonquery()
Next()
connclose()

            If I <= 0 Then
MessageBox.Show("Items Added Fool")
DataGridView1.Refresh()

hope this will works fine for you

Regards

;

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

try to move toword automation by using RFID tags , singles , cards etc , and yes you can also work in some advance database applications , like ERP solutions , University student management system , etc .
Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello!
i am facing an error ("object refrence is not set to an instance of an object.") i check my all code but i can able to solve it . here is a line of code where i getting it.

.
.
.
cmd = new sqlcommand(_mycommand_)

if (__mycondition)
{
serialNo = convert.ToInt16(cmd.executeScalar().toString());//----here i got an error
// as serialNo is a variable defined publicaly in my struct and datatype of it is int
}

please help me in this , so that i can move forword.

Best regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

i think first you have to set then format of your datetime picker so that it can only show the time then just simple bind it with your datasource.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

i think you have to use a simple code which you used to populate your combobox what you have to do it to use a query with where clause and use that query to populate the combo call that query at your first combo where you select the brandy. you code may be look like this.
dim con as new sqlconnnection("your connection string")
dim da as new sqldataadapter("select productname from table where brandy="&cmbBrandy.text,con)
con.open()
dim dt as new datatable()
da.fill(dt)
comboproduct.datasource= dt
comboproduct.displayfield="productname"
con.close()

hope this will give you an idea .

Best Regards

M.Waqas Aslam

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

well first you have to select the reporting tool to make reports , like crystal reports , telerik reports , and also active x report etc , then google that how to make the specific reports , after this you will be able to make reports you want to create.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello!
i am working on a client and server application , i want to connect my server with my client application to perform some database transactions.i think it is very simple to connect a client with the server , but here is the point , i have two pc , one has win xp professional and other has windows server 2008 , now the mssql server is installed at the pc win xp .is it importent to install my mssql server at the windows server in order to access it , or i can do it in the way i want , please guide me , in this , i googled so many sites , and youtube videos but no one is able to solve it . please guid me.

Regards

M.Waqas Aslam

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

replace this

TextBoxDataKode.Text = DGS4.Item(1, GridView.SelectedRows(0).Index).Value

with this

TextBoxDataKode.Text = DGS4.Item(1, DGS4.currentrow.Index).Value.tostring()

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

i cant get your point , but for getting id , you can get the max id by using datareader and then +1 and show it to your textbox.it is very simple.now can you please little bit explain your point. do you want to create whole form consisting of textboxes , grid dynamically ? or something else?

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

i think you have to use the where clause instead of having .just for your information WHERE is used to filter rows. HAVING is usually used to filter rows after performing an aggregation.now in your case you are filtering rows and want to showrecords those fulfil your criteria . you have to use where clause .

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

yes you can do like what saleem says , but tell me how you are getting the rate of the product , ? then we are able to provide you useful code .

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

in this code you are just dealing with customer table , just you should have one thing always in your mind , always first delete the related record then the main records , for example we have a customer name ali , now we also have 3 records in table books , in order to delete ali from the customer we have to delete 3 records of ali from the table books ,now use same code and just change the query and in query just change the name of table , then after execute the query and deleting the records form the table books then delete record of your perticular customer.

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

it is very hard to type code in this new format , please i am very sorry to post twice , and my code is like a comment please read it carefuly .

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

well , it is much better if you tell us about the column of your grid , now lets assume you have two columns in your gird column 1 is roll no and column two is name , now we gernate a email like this , hello!
this is auto gerenated email ,mr------ , your new roll no is ------- .
Regards,
for above format we can do like this .

Code blocks are created by indenting at least 4 spaces
... and can span multiple lines
dim i as integer 
for i = 0 to datagrid.rows.count-1
dim name,rollno as string
name =  datagrid.item(1,i).value.tostring
rollno= datagrid.item(0,i).value.tostring
 'your email code here and  use this line in place of mail.body
 mail.Body ="hello!" & vbcrlf & "this is auto gerenated email ,mr "& name & ", your new roll no is "& rollno& "." & vbcrlf & "Regards."

next

hope this will give you idea , how to send emails after getting some values from the grid ,

Best Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

well , it is much better if you tell us about the column of your grid , now lets assume you have two columns in your gird column 1 is roll no and column two is name , now we gernate a email like this , hello!
this is auto gerenated email ,mr------ , your new roll no is ------- .
Regards,
for above format we can do like this .

Code blocks are created by indenting at least 4 spaces
... and can span multiple lines
dim i as integer 
for i = 0 to datagrid.rows.count-1
dim name,rollno as string
name =  datagrid.item(1,i).value.tostring
rollno= datagrid.item(0,i).value.tostring
 'your email code here and  use this line in place of mail.body
 mail.Body ="hello!" & vbcrlf & "this is auto gerenated email ,mr "& name & ", your new roll no is "& rollno& "." & vbcrlf & "Regards."

next

hope this will give you idea , how to send emails after getting some values from the grid ,

Best Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

saleem please try to read y post again

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

thanks sir darkagn and sir pritaeas , for your valuable time . thread is solved :)

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

well , you can do this by declaring a global variable , named invoiceno , and then get the value of invoice from the grid and use that value at the new form load event , for example you have two forms , frmchoose , frmshow, and a global variable name invoiceno. now use this code.

'at the double click of your grid
invoiceno = datagrid.item(0,datagrid.currentrow.index).value.tostring()
frmshow.show()

'now assume you have a query through which you are filtrng records , now do like this
sql = "select * from sales where invoiceno="& invoiceno

may be this will solve your prob
Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

well , i checked your code , and both are giving same value of time , as i mentioned in my previous post that please set the property of your datetimepicker from format to custom and in custom write hh:mm , but your code is much better then mines , as there is no need to set these properties when someone using your code.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

yes off cource , please post your code ,

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

try this

sql = "select * from tblSchdule where CheckIn between '" & DateTimePicker2.Value.date.ToString() & " and '" & DateTimePicker2.Value.date.ToString() & "'"

Hope this will work fine.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

if done then please mark this thread as solved .

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

i cant get you pooja , what do you mean by instance , well if you just want to know is * is in text file ? please check this attachment.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

@anuj6928 , please have a look at this .http://www.daniweb.com/forums/attachment.php?attachmentid=24199&d=1331971661 , in this grid , we have a column , and we have something like this 12:18:00 , so i just add :00 to the string so that it will be equal to that field . this is not the ideal solution , there is much more to improve .
thanks for your interest .

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

just change your query with this.

sql = "select * from tblSchdule where CheckIn between '" & DateTimePicker2.Value.ToShortDateString() & " and '" & DateTimePicker2.Value.ToShortDateString() & "'"

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

ok check this put , hope this will works fine.

dim i as integer
for i = 0 to datagridview.rows.count-1
dim a,b as string 
a = datetimepicker.text & ":00"
b = now.date.tostring()
if a = datagridview.item(6,i).value.tostring() and  b = datagridview.item(2,i).value.tostring()
    //place your email sending code here 
end if 

next

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

It's just pause for user to fill out that groupbox and then continue with counter+1 ...not stop...

please check this attached file , hope this will solve your prob.


Regards