Monday, March 19, 2012

how to find that the table column exists through program

i need to check that the column exist in the table if yes the update/insert value in the column else i need to add the new column like new browser name in the table.

after the search i found some thing like and make the procedure like

Dim daAs SqlDataAdapter, dsAs DataSet, dcAs DataColumn, foundsAsBoolean

Try

Conn.Open()

cmd =New SqlCommand(str, Conn)

da =New SqlDataAdapter(cmd)

ds =New DataSet

da.Fill(ds,"tbls")

ForEach dcIn ds.Tables(0).Columns

If UCase(colnames) = UCase(dc.ColumnName)Then

founds =True

ExitFor

Else

founds =False

EndIf

Next

Catch exAs Exception

Finally

Conn.Close()

EndTry

Return founds

sugesstions on this is required.................

No comments:

Post a Comment