Related
Why I continue getting the error :
missing 1 required positional argument: 'category_id'
when the argument is already passed within query function in Backend class? I also don't understand the error of unfilled self or missing positional argument self:
missing 1 required positional argument: 'self'
I tried passing self to display_account_types() in Frontend class but it doesn't reflect. Do I need to pass self within the inner nested functions within a class?
import tkinter
from tkinter import *
from tkinter import ttk
import tkinter.messagebox
import sqlite3
root =Tk()
root.title('Simple Application')
root.config(bg='SlateGrey')
root.geometry("")
# BackEnd
class Backend():
def __init__(self):
self.conn = sqlite3.connect('accounting.db')
self.cur = self.conn.cursor()
self.conn.execute("""CREATE TABLE IF NOT EXISTS account_type(
id INTEGER PRIMARY KEY,
category_type INTEGER NOT NULL,
category_id TEXT NOT NULL
)"""),
self.conn.commit()
self.conn.close()
def insert_account_type(self, category_type, category_id):
self.conn = sqlite3.connect('accounting.db')
self.cur = self.conn.cursor()
self.cur.execute("""INSERT INTO account_type(category_id, category_type) VALUES(?,?);""",
(self,category_type, category_id,))
self.conn.commit()
self.conn.close()
def view_account_type(self):
self.conn = sqlite3.connect('accounting.db')
self.cur = self.conn.cursor()
self.cur.execute("SELECT * FROM account_type")
self.rows = self.cur.fetchall()
self.conn.close()
return self.rows
# calling the class
tb = Backend()
# Front End
class Frontend():
def __init__(self, master):
# Frames
self.top_frame = LabelFrame(master,bg ='SlateGrey', relief=SUNKEN)
self.top_frame.pack()
self.bottom_frame = LabelFrame(master, bg = 'SlateGrey', relief=SUNKEN)
self.bottom_frame.pack()
self.right_frame = LabelFrame(self.top_frame, bg = 'SlateGrey', relief = FLAT,
text = 'Details Entry',fg = 'maroon')
self.right_frame.pack(side = RIGHT, anchor = NE)
self.side_frame = LabelFrame(self.top_frame,bg ='SlateGrey',relief=SUNKEN,text = 'Menu Buttons',fg = 'maroon')
self.side_frame.pack(side = LEFT,anchor = NW)
self.bot_frame = LabelFrame(self.bottom_frame, bg='Grey',relief = SUNKEN,text = 'Field View',fg = 'maroon')
self.bot_frame.pack(side = BOTTOM,anchor = SW)
# Side Buttons
self.btn1 = Button(self.side_frame,
text='Main Account Types',
bg='SteelBlue4',
font=('cambria', 11),
anchor=W,
fg='white',
width=18,height=2,
command=lambda :[self.main_account()])
self.btn1.grid(row=0, column=0, pady=0, sticky=W)
def main_account(self):
# variables
self.category_type = StringVar()
self.category_id = StringVar()
# functions
def add_main_accounts():
if self.category_type.get() == "" or self.category_id.get() == "":
tkinter.messagebox.showinfo('All fields are required')
else:
Backend.insert_account_type(
self.category_type.get(),
self.category_id.get(),) # category type unfilled
tkinter.messagebox.showinfo('Entry successful')
def display_account_types(self):
self.trv.delete(*self.trv.get_children())
for self.rows in Backend.view_account_type(self):
self.trv.insert("", END, values=self.rows)
def get_account_type(e):
self.selected_row = self.trv.focus()
self.data = self.trv.item(self.selected_row)
global row
row = self.data["values"]
"""Grab items and send them to entry fields"""
self.category_id.set(row[1])
self.category_type.set(row[2])
"""=================TreeView==============="""
# Scrollbars
ttk.Style().configure("Treeview", background = "SlateGrey", foreground = "white", fieldbackground = "grey")
scroll_x = Scrollbar(self.bot_frame, orient = HORIZONTAL)
scroll_x.pack(side = BOTTOM, fill = X)
scroll_y = Scrollbar(self.bot_frame, orient = VERTICAL)
scroll_y.pack(side = RIGHT, fill = Y)
# Treeview columns & setting scrollbars
self.trv = ttk.Treeview(self.bot_frame, height=3, columns=
('id', 'category_id', 'category_type'), xscrollcommand = scroll_x.set, yscrollcommand = scroll_y.set)
# Treeview style configuration
ttk.Style().configure("Treeview", background = "SlateGrey", foreground = "white", fieldbackground = "grey")
# Configure vertical and Horizontal scroll
scroll_x.config(command = self.trv.xview)
scroll_y.config(command = self.trv.yview)
# Treeview Headings/columns
self.trv.heading('id', text = "No.")
self.trv.heading('category_id', text = 'Category ID')
self.trv.heading('category_type', text = 'Category Type')
self.trv['show'] = 'headings'
# Treeview columns width
self.trv.column('id', width = 23)
self.trv.column('category_id', width = 70)
self.trv.column('category_type', width = 100)
self.trv.pack(fill = BOTH, expand = YES)
# Binding Treeview with data
self.trv.bind('<ButtonRelease-1>',get_account_type)
# Account Types Labels
self.lbl1 = Label(self.right_frame,text = 'Category ID',anchor = W,
width=10,font = ('cambria',11,),bg = 'SlateGrey')
self.lbl1.grid(row = 0,column = 0,pady = 5)
self.lbl2 = Label(self.right_frame, text = 'Category Type', anchor = W,
width = 10,font = ('cambria',11,),bg = 'SlateGrey')
self.lbl2.grid(row = 1, column = 0,pady = 5,padx=5)
self.blank_label = Label(self.right_frame, bg='SlateGrey')
self.blank_label.grid(row=2, columnspan=2, pady=10)
# Account Type Entries
self.entry1 = Entry(self.right_frame,textvariable = self.category_id,
font = ('cambria',11,),bg = 'Grey',width=14)
self.entry1.grid(row = 0,column=1,sticky = W,padx = 5)
self.entry2 = Entry(self.right_frame, textvariable = self.category_type,
font = ('cambria', 11,), bg = 'Grey',width = 14)
self.entry2.grid(row = 1, column = 1, sticky = W,pady = 5,padx = 5)
# Buttons
self.btn_1 = Button(self.right_frame,text = 'Add',font = ('cambria',12,'bold'),bg = 'SlateGrey',
activebackground='green', fg = 'white',width=12,height = 2,relief=RIDGE,
command = lambda :[add_main_accounts()])
self.btn_1.grid(row = 3,column = 0,pady = 15)
self.btn_2 = Button(self.right_frame, text = 'View', font = ('cambria', 12, 'bold'),
bg = 'SlateGrey',command=lambda :[display_account_types()],
activebackground='green', fg ='white', width=12, height = 2, relief = RIDGE)
self.btn_2.grid(row = 3, column = 1)
# calling the class
app = Frontend(root)
root.mainloop()
I got and answer to this question,
I just passed in the 'self' argument to the inner nested functions of the class as below and it worked.
# functions
def add_main_accounts(self):
if self.category_id.get() == "" or self.category_type.get() == "":
tkinter.messagebox.showinfo('All fields are required')
else:
Backend.insert_account_type(self,
self.category_id.get(),
self.category_type.get()) # category type unfilled
tkinter.messagebox.showinfo('Entry successful')
def display_account_types(self):
self.trv.delete(*self.trv.get_children())
for rows in Backend.view_account_type(self):
self.trv.insert("", END, values = rows)
return
def get_account_type(e):
self.selected_row = self.trv.focus()
self.data = self.trv.item(self.selected_row)
global row
self.row = self.data["values"]
"""Grab items and send them to entry fields"""
self.category_id.set(row[1])
self.category_type.set(row[2])
I think you should remove the self in display_account_types function like you did to the previous one.
Private Sub Arr(ByVal arrRad() As RadioButton, ByVal arrLbl() As Label)
Dim result As Integer = 0
Dim temp As Integer = 0
'arrRad is my control array Radiobutton, arrLbl is my control array Label
'I have 15 Radiobutton and 3 Label
For i As Integer = 0 To arrRad.Length - 1 Step 5
If arrRad(i).Checked = True Then
temp = arrRad(i).Text.Substring(0, 1)
ElseIf arrRad(i + 1).Checked = True Then
temp = arrRad(i + 1).Text.Substring(0, 1)
ElseIf arrRad(i + 2).Checked = True Then
temp = arrRad(i + 2).Text.Substring(0, 1)
ElseIf arrRad(i + 3).Checked = True Then
temp = arrRad(i + 3).Text.Substring(0, 1)
ElseIf arrRad(i + 4).Checked = True Then
temp = arrRad(i + 4).Text.Substring(0, 1)
Else
temp = 0
End If
result += temp
Next
txtKetQua.Text = result.ToString()
End Sub
I want to show lblError if that row radiobutton is unchecked, but I don't know how to show it
P/s: Sorry for my bad English
You can do it in a very shorter way using LInQ Extension .Any():
lblError.Visible = Not arrRad.Any(Function(rb) rb.Ckecked)
My program is for a hangman game and I can't get the window to refresh once the button is clicked. At least i think that is the problem Here is my code for the window and the function linked to the button, let me know if you need more code:
def game(self, num):
self.game_window = tkinter.Tk()
self.game_window.title('Hangman')
self.game_window.geometry('200x150')
self.f1 = tkinter.Frame(self.game_window)
self.f2 = tkinter.Frame(self.game_window)
self.f3 = tkinter.Frame(self.game_window)
self.f4 = tkinter.Frame(self.game_window)
self.f5 = tkinter.Frame(self.game_window)
self.f6 = tkinter.Frame(self.game_window)
self.f7 = tkinter.Frame(self.game_window)
self.f8 = tkinter.Frame(self.game_window)
self.f9 = tkinter.Frame(self.game_window)
self.num = num
word_list = ['PYTHON','SOMETHING','COMPLETELY','DIFFERENT',
'LIST','STRING','SYNTAX','OBJECT','ERROR',
'EXCEPTION','OBJECT','CLASS','PERFORMANCE','VISUAL',
'JAVASCRIPT','JAVA','PROGRAMMING','TUPLE','ASSIGN',
'FUNCTION','OPERATOR','OPERANDS','PRECEDENCE',
'LOOPS','SENTENCE','TABLE','NUMBERS','DICTIONARY',
'GAME','SOFTWARE','NETWORK','SOCIAL','EDUCATION',
'MONITOR','COMPUTER']
shuffle = random.shuffle(word_list)
rand = random.choice(word_list)
self.word = rand.lower()
self.current = len(self.word)*'*'
self.letters = []
#self.start_lives = tkinter.Label(self.f1, text = 'You\'ve started the '
#'game with %s lives.\n'%(self.num))
#self.start_lives.pack(side = 'left')
self.lives_rem = tkinter.Label(self.f2,
text = 'Lives remaining: '+str(self.lives_left()))
self.lives_rem.pack(side = 'left')
self.guess_letter = tkinter.Label(self.f3, text = 'Guess a letter: ')
self.guess_entry = tkinter.Entry(self.f3, width = 10)
self.guess_letter.pack(side = 'left')
self.guess_entry.pack(side = 'left')
#self.f1.pack()
self.f2.pack()
self.f3.pack()
self.guess_button = tkinter.Button(self.f6,
text = 'Guess!',
command = self.update(self.guess_entry.get()))
self.guess_button.pack(side = 'left')
self.quit_game = tkinter.Button(self.f6,
text = 'Quit Game',
command = self.game_window.destroy)
self.quit_game.pack(side = 'left')
self.f6.pack()
def update(self, letter):
if letter in self.word and letter not in self.letters:
pos = self.word.index(letter)
self.current1 = list(self.current)
self.current1[pos] = letter.upper()
self.current2 = ''.join(self.current1)
self.letters.append(letter)
elif letter in self.letters:
self.already_guessed = tkinter.messagebox.showinfo('Error!',
'This letter has already '
'been guessed')
#letter is not in the word
elif letter not in self.word:
self.sorry = tkinter.Label(self.f5,
text = 'Sorry, guess again!')
self.sorry.pack(side = 'left')
self.letters.append(letter)
self.num -= 1
self.incorrect_word = tkinter.Label(self.f4,
text = 'Word: '+self.current)
self.incorrect_word.pack(side='left')
self.f5.pack()
self.f4.pack()
return self.current
These are two methods in a Hangman class.
The line that defines the guess button:
self.guess_button = tkinter.Button(self.f6, text = 'Guess!', command = self.update(self.guess_entry.get()))
requires modification. the command argument for the Button class should be a function, but this line is calling that function (which sends the output of the function as the value for the command argument). As you may see on the quit_game button definition, the self.game_window.destroy function is provided as the command, but is not called right now.
I suggest changing this line like this:
self.guess_button = tkinter.Button(self.f6, text = 'Guess!', command = self._on_guess_button_click)
and then add a new method to your class like this:
def _on_guess_button_click (self):
self.update(self.guess_entry.get())
I want to insert and update data into database on button click but when I fill all fields and start debugging and when dubugger is on buyer code this error is occurred "object reference not set to an instance of an object". Kindly help me.......
protected void btnSaveChanges_Click(object sender, EventArgs e)
{
if (Convert.ToInt32(ViewState["BuyerId"]) > 0)
{
oBuyer = new Buyer();
//Fill object with Text box values
oBuyer.BuyerId = Convert.ToInt32(ViewState["BuyerId"]);
oBuyer.BuyerCode = txtBuyerCode.Text;
oBuyer.SunCode = txtSunCode.Text;
oBuyer.BuyerName = txtBuyerName.Text;
oBuyer.BuyerAddress1 = txtBuyerAddress1.Text;
oBuyer.BuyerAddress2 = txtBuyerAddress2.Text;
oBuyer.BuyerAddress3 = txtBuyerAddress3.Text;
oBuyer.BuyerAddress4 = txtBuyerAddress4.Text;
oBuyer.BuyerPostCode = txtBuyerPostcode.Text;
oBuyer.BuyerPhone = txtBuyerPhone.Text;
oBuyer.BuyerFax = txtBuyerFax.Text;
oBuyer.BuyerEmail = txtBuyerMail.Text;
oBuyer.PfaCode = txtBuyerPFACode.Text;
oBuyer.Guarantee = Convert.ToDecimal(txtBuyerGuarantee.Text);
oBuyer.DefaultDestination = ddlBuyerDefaultDestination.SelectedValue;
oBuyer.HbaLevy = chkHBALeavy.Checked;
oBuyer.SfiaWhite = chkSFIAPelagic.Checked;
oBuyer.SfiaPelagic = chkSFIAPelagic.Checked;
oBuyer.MarketBox = txtBuyerMarketBox.Text;
oBuyer.Comments = txtComments.Text;
oBuyer.BuyerRegistrationNo = txtBuyerRigistrationNo.Text;
}
else
{
//Fill object with Text box values
oBuyer.BuyerCode = txtBuyerCode.Text;
oBuyer.SunCode = txtSunCode.Text;
oBuyer.BuyerName = txtBuyerName.Text;
oBuyer.BuyerAddress1 = txtBuyerAddress1.Text;
oBuyer.BuyerAddress2 = txtBuyerAddress2.Text;
oBuyer.BuyerAddress3 = txtBuyerAddress3.Text;
oBuyer.BuyerAddress4 = txtBuyerAddress4.Text;
oBuyer.BuyerPostCode = txtBuyerPostcode.Text;
oBuyer.BuyerPhone = txtBuyerPhone.Text;
oBuyer.BuyerFax = txtBuyerFax.Text;
oBuyer.BuyerEmail = txtBuyerMail.Text;
oBuyer.PfaCode = txtBuyerPFACode.Text;
oBuyer.Guarantee = Convert.ToDecimal(txtBuyerGuarantee.Text);
oBuyer.DefaultDestination = ddlBuyerDefaultDestination.SelectedValue;
oBuyer.HbaLevy = chkHBALeavy.Checked;
oBuyer.SfiaWhite = chkSFIAPelagic.Checked;
oBuyer.SfiaPelagic = chkSFIAPelagic.Checked;
oBuyer.MarketBox = txtBuyerMarketBox.Text;
oBuyer.Comments = txtComments.Text;
oBuyer.BuyerRegistrationNo = txtBuyerRigistrationNo.Text;
}
//enter into nSYScatch6 service
bool saveBuyer = nSYSCatch6ServiceInitiator.SaveBuyer(oBuyer);
if (saveBuyer)
{
}
Response.Redirect(Request.RawUrl);
}
You are missing an oBuyer = new Buyer(); in the else branch.
Question Edit because simple table doesnt make things simpler..
The issue is i have to pick dynamic column value..
the column name came from prev page (DropDownList) => Current Page (HiddenField)
This is my Current Codes:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using System.Data;
public partial class ViewChart : System.Web.UI.Page
{
BlupDataContext database = new BlupDataContext();
protected void Page_Load(object sender, EventArgs e)
{
HiddenFieldWCellName.Value = Request.QueryString["WCEL_Name"];
HiddenFieldSeries1.Value = Request.QueryString["Series1"];
HiddenFieldSeries2.Value = Request.QueryString["Series2"];
var q = from x in database.RSRAN079s
join y in database.RSRAN084s
on x.WCEL_Name equals y.WCEL_Name
where x.WCEL_Name == HiddenFieldWCellName.Value
select new
{
RSRAN079_ID = x.RSRAN079_ID,
PeriodStartTime = x.PeriodStartTime,
PLMN_Name = x.PLMN_Name,
RNC_Name = x.RNC_Name,
WBTS_Name = x.WBTS_Name,
WBTS_ID = x.WBTS_ID,
WCEL_Name = x.WCEL_Name,
WCEL_ID = x.WCEL_ID,
RRC_Conn_Access_Completitions = x.RRC_Conn_Access_Completitions,
RRC_Active_Drops_IU_FR = x.RRC_Active_Drops_IU_FR,
RRC_Active_Drops_IU_Fails = x.RRC_Active_Drops_IU_Fails,
RRC_Active_Drops_Radio_FR = x.RRC_Active_Drops_Radio_FR,
RRC_Active_Drops_Radio_Fails = x.RRC_Active_Drops_Radio_Fails,
RRC_Active_Drops_BTS_FR = x.RRC_Active_Drops_BTS_FR,
RRC_Active_Drops_BTS_Fails = x.RRC_Active_Drops_BTS_Fails,
RRC_Active_Drops_IUR_FR = x.RRC_Active_Drops_IUR_FR,
RRC_Active_Drops_IUR_Fails = x.RRC_Active_Drops_IUR_Fails,
RRC_Active_Drops_CIPH_FR = x.RRC_Active_Drops_CIPH_FR,
RRC_Active_Drops_CIPH_Fails = x.RRC_Active_Drops_CIPH_Fails,
RRC_Active_Drops_RNC_FR = x.RRC_Active_Drops_RNC_FR,
RRC_Active_Drops_RNC_Fails = x.RRC_Active_Drops_RNC_Fails,
RRC_Active_Drops_UE_FR = x.RRC_Active_Drops_UE_FR,
RRC_Active_Drops_UE_Fails = x.RRC_Active_Drops_UE_Fails,
RAB_Retainability_CS_Voice_SR = x.RAB_Retainability_CS_Voice_SR,
RAB_Retainability_CS_Conv_SR = x.RAB_Retainability_CS_Conv_SR,
RAB_Retainability_PS_SR = x.RAB_Retainability_PS_SR,
AMR_RAB_Setup_Access_Completitions = x.AMR_RAB_Setup_Access_Completitions,
AMR_RAB_Drop_Active_Drops_IF_FR = x.AMR_RAB_Drop_Active_Drops_IF_FR,
AMR_RAB_Drop_Active_Drops_IU_Fails = x.AMR_RAB_Drop_Active_Drops_IU_Fails,
AMR_RAB_Drop_Active_Drops_Radio_FR = x.AMR_RAB_Drop_Active_Drops_Radio_FR,
AMR_RAB_Drop_Active_Drops_Radio_Fails = x.AMR_RAB_Drop_Active_Drops_Radio_Fails,
AMR_RAB_Drop_Active_Drops_BTS_FR = x.AMR_RAB_Drop_Active_Drops_BTS_FR,
AMR_RAB_Drop_Active_Drops_BTS_Fails = x.AMR_RAB_Drop_Active_Drops_BTS_Fails,
AMR_RAB_Drop_Active_Drops_IUR_FR = x.AMR_RAB_Drop_Active_Drops_IUR_FR,
AMR_RAB_Drop_Active_Drops_IUR_Fails = x.AMR_RAB_Drop_Active_Drops_IUR_Fails,
AMR_RAB_Drop_Active_Drops_RNC_FR = x.AMR_RAB_Drop_Active_Drops_RNC_FR,
AMR_RAB_Drop_Active_Drops_RNC_Fails = x.AMR_RAB_Drop_Active_Drops_RNC_Fails,
AMR_RAB_Drop_Active_Drops_UE_FR = x.AMR_RAB_Drop_Active_Drops_UE_FR,
AMR_RAB_Drop_Active_Drops_UE_Fails = x.AMR_RAB_Drop_Active_Drops_UE_Fails,
CS_Conv_RAB_Setup_Access_Completitions = x.CS_Conv_RAB_Setup_Access_Completitions,
CS_Conv_RAB_Retainability_Completitions = x.CS_Conv_RAB_Retainability_Completitions,
CS_Conv_RAB_Active_Drops_IU_FR = x.CS_Conv_RAB_Active_Drops_IU_FR,
CS_Conv_RAB_Active_Drops__IU_Fails = x.CS_Conv_RAB_Active_Drops__IU_Fails,
CS_Conv_RAB_Active_Drops_Radio_FR = x.CS_Conv_RAB_Active_Drops_Radio_FR,
CS_Conv_RAB_Active_Drops_Radio_Fails = x.CS_Conv_RAB_Active_Drops_Radio_Fails,
CS_Conv_RAB_Active_Drops_BTS_FR = x.CS_Conv_RAB_Active_Drops_BTS_FR,
CS_Conv_RAB_Active_Drops_BTS_Fails = x.CS_Conv_RAB_Active_Drops_BTS_Fails,
CS_Conv_RAB_Active_Drops_IUR_FR = x.CS_Conv_RAB_Active_Drops_IUR_FR,
CS_Conv_RAB_Active_Drops_IUR_Fails = x.CS_Conv_RAB_Active_Drops_IUR_Fails,
CS_Conv_RAB_Active_Drops_RNC_FR = x.CS_Conv_RAB_Active_Drops_RNC_FR,
CS_Conv_RAB_Active_Drops_RNC_Fails = x.CS_Conv_RAB_Active_Drops_RNC_Fails,
CS_Conv_RAB_Active_Drops_UE_FR = x.CS_Conv_RAB_Active_Drops_UE_FR,
CS_Conv_RAB_Active_Drops_UE_Fails = x.CS_Conv_RAB_Active_Drops_UE_Fails,
Packet_Service_RAB_Setup_Access_Completitions = x.Packet_Service_RAB_Setup_Access_Completitions,
Packet_Service_RAB_Retainability_Completitions = x.Packet_Service_RAB_Retainability_Completitions,
Packet_Service_RAB_Active_Drops_IU_FR = x.Packet_Service_RAB_Active_Drops_IU_FR,
Packet_Service_RAB_Active_Drops_Fails = x.Packet_Service_RAB_Active_Drops_Fails,
Packet_Service_RAB_Active_Drops_Radio_FR = x.Packet_Service_RAB_Active_Drops_Radio_FR,
Packet_Service_RAB_Active_Drops_Radio_Fails = x.Packet_Service_RAB_Active_Drops_Radio_Fails,
Packet_Service_RAB_Active_Drops_BTS_FR = x.Packet_Service_RAB_Active_Drops_BTS_FR,
Packet_Service_RAB_Active_Drops_BTS_Fails = x.Packet_Service_RAB_Active_Drops_BTS_Fails,
Packet_Service_RAB_Active_Drops_IUR_FR = x.Packet_Service_RAB_Active_Drops_IUR_FR,
Packet_Service_RAB_Active_Drops_IUR_Fails = x.Packet_Service_RAB_Active_Drops_IUR_Fails,
Packet_Service_RAB_Active_Drops_RNC_FR = x.Packet_Service_RAB_Active_Drops_RNC_FR,
Packet_Service_RAB_Active_Drops_RNC_Fails = x.Packet_Service_RAB_Active_Drops_RNC_Fails,
Packet_Service_RAB_Active_Drops_UE_FR = x.Packet_Service_RAB_Active_Drops_UE_FR,
Packet_Service_RAB_Active_Drops_UE_Fails = x.Packet_Service_RAB_Active_Drops_UE_Fails,
Packet_Session_Rel_HSDSCH_EDCH = x.Packet_Session_Rel_HSDSCH_EDCH,
Packet_Session_Rel_HSDSCH_DCH = x.Packet_Session_Rel_HSDSCH_DCH,
Packet_Session_Rel_Alloc_Rel = x.Packet_Session_Rel_Alloc_Rel,
Packet_Session_Success_Ratio_SR = x.Packet_Session_Success_Ratio_SR,
Packet_Session_Drops_HSDSCH_EDCH_DR = x.Packet_Session_Drops_HSDSCH_EDCH_DR,
Packet_Session_Drops_HSDSCH_EDCH_Drops = x.Packet_Session_Drops_HSDSCH_EDCH_Drops,
Packet_Session_Drops_HSDSCH_DCH_DR = x.Packet_Session_Drops_HSDSCH_DCH_DR,
Packet_Session_Drops_HSDSCH_DCH_Drops = x.Packet_Session_Drops_HSDSCH_DCH_Drops,
Packet_Session_Drops_DCH_DR = x.Packet_Session_Drops_DCH_DR,
Packet_Session_Drops_DCH_Drops = x.Packet_Session_Drops_DCH_Drops,
Packet_Session_Drops_HSDSCH_EDCH_Other_DR = x.Packet_Session_Drops_HSDSCH_EDCH_Other_DR,
Packet_Session_Drops_HSDSCH_EDCH_Other_Drops = x.Packet_Session_Drops_HSDSCH_EDCH_Other_Drops,
Packet_Session_Drops_HSDSCH_DCH_Other_DR = x.Packet_Session_Drops_HSDSCH_DCH_Other_DR,
Packet_Session_Drops_HSDSCH_DCH_Other_Drops = x.Packet_Session_Drops_HSDSCH_DCH_Other_Drops,
Packet_Session_Drops_DCH_Other_DR = x.Packet_Session_Drops_DCH_Other_DR,
Packet_Session_Drops_DCH_Other_Drops = x.Packet_Session_Drops_DCH_Other_Drops,
HSDSCH_Alloc_Rel = x.HSDSCH_Alloc_Rel,
HSDPA_Retain_NW = x.HSDPA_Retain_NW,
HSDPA_Retain_RL_FR = x.HSDPA_Retain_RL_FR,
HSDPA_Retain_Non_RL_FR = x.HSDPA_Retain_Non_RL_FR,
HSDPA_Retain_Mobility_FR = x.HSDPA_Retain_Mobility_FR,
HSDPA_Retain_PRE_EMPTION_FR = x.HSDPA_Retain_PRE_EMPTION_FR,
HSDPA_Retain_Other_Mob_FR = x.HSDPA_Retain_Other_Mob_FR,
EDCH_Alloc_Rel = x.EDCH_Alloc_Rel,
HSUPA_Retain_NW = x.HSUPA_Retain_NW,
HSUPA_Retain_RL_FR = x.HSUPA_Retain_RL_FR,
HSUPA_Retain_EDCH_Rel_HSDSCH_SCC = x.HSUPA_Retain_EDCH_Rel_HSDSCH_SCC,
HSUPA_Retain_Other_FR = x.HSUPA_Retain_Other_FR,
HSDSCH_SCC_UE_FR = x.HSDSCH_SCC_UE_FR,
HSDSCH_SCC_UE_Fails = x.HSDSCH_SCC_UE_Fails,
HSDSCH_SCC_BTS_FR = x.HSDSCH_SCC_BTS_FR,
HSDSCH_SCC_BTS_Fails = x.HSDSCH_SCC_BTS_Fails,
HSDSCH_SCC_Trans_FR = x.HSDSCH_SCC_Trans_FR,
HSDSCH_SCC_Trans_Fails = x.HSDSCH_SCC_Trans_Fails,
HSDSCH_SCC_AC_FR = x.HSDSCH_SCC_AC_FR,
HSDSCH_SCC_AC_Fails = x.HSDSCH_SCC_AC_Fails,
HSDSCH_SCC_Other_FR = x.HSDSCH_SCC_Other_FR,
HSDSCH_SCC_Other_Fails = x.HSDSCH_SCC_Other_Fails,
R99_Alloc_Rel = x.R99_Alloc_Rel,
R99_Retain_NW = x.R99_Retain_NW,
Inter_RNC_SCC_Fail = x.Inter_RNC_SCC_Fail,
Inter_RNC_SCC_Drop = x.Inter_RNC_SCC_Drop,
RSRAN084_ID = y.RSRAN084_ID,
PeriodStartTime2 = y.PeriodStartTime,
RNC_Name2 = y.RNC_Name,
WBTS_Name2 = y.WBTS_Name,
WBTS_ID2 = y.WBTS_ID,
WCEL_Name2 = y.WCEL_Name,
WCEL_ID2 = y.WCEL_ID,
Cell_Availability = y.Cell_Availability,
Cell_Availability_Exclude = y.Cell_Availability_Exclude,
RRC_Set_Att = y.RRC_Set_Att,
RRC_Set_Acc_CR_NW = y.RRC_Set_Acc_CR_NW,
RRC_Set_Acc_CR_UE = y.RRC_Set_Acc_CR_UE,
RRC_Conn_Setup_SR = y.RRC_Conn_Setup_SR,
RRC_Conn_SR = y.RRC_Conn_SR,
RRC_Reg_Att = y.RRC_Reg_Att,
Regist_SR = y.Regist_SR,
RAB_Att_Voice = y.RAB_Att_Voice,
RAB_STP_and_ACC_CR_Voice = y.RAB_STP_and_ACC_CR_Voice,
RAB_SR_AMR_Voice = y.RAB_SR_AMR_Voice,
Min_per_Drop_Voice = y.Min_per_Drop_Voice,
CS_Serv_Dur_Voice = y.CS_Serv_Dur_Voice,
RAB_Att_UDI = y.RAB_Att_UDI,
RAB_Stp_Acc_SR = y.RAB_Stp_Acc_SR,
RAB_SR_UDI = y.RAB_SR_UDI,
Min_Per_Drop_UDI = y.Min_Per_Drop_UDI,
CS_Serv_Dur_UDI = y.CS_Serv_Dur_UDI,
PS_NRT_RAB_Att = y.PS_NRT_RAB_Att,
PS_NRT_RAB_CR = y.PS_NRT_RAB_CR,
PS_NRT_RAB_SR_NW = y.PS_NRT_RAB_SR_NW,
PS_NRT_RAB_SR_User = y.PS_NRT_RAB_SR_User,
Packet_Session_Att = y.Packet_Session_Att,
Packet_Session_Stp_SR = y.Packet_Session_Stp_SR,
RAB_Att_Stream = y.RAB_Att_Stream,
RAB_Stp_Acc_SR_Stream = y.RAB_Stp_Acc_SR_Stream,
RAB_SR_Stream = y.RAB_SR_Stream,
M_RAB_Att = y.M_RAB_Att,
M_RAB_Stp_Acc_SR = y.M_RAB_Stp_Acc_SR,
M_RAB_SR = y.M_RAB_SR,
SHO_Update_Att_RT = y.SHO_Update_Att_RT,
SHO_Update_Att_NRT = y.SHO_Update_Att_NRT,
SHO_SR_RT = y.SHO_SR_RT,
SHO_SR_NRT = y.SHO_SR_NRT,
SHO_Overhead = y.SHO_Overhead,
Inter_Sys_HHO_Att_RT = y.Inter_Sys_HHO_Att_RT,
Inter_Sys_HHO_Att_NRT = y.Inter_Sys_HHO_Att_NRT,
Inter_Sys_HHO_RT_SR = y.Inter_Sys_HHO_RT_SR,
Inter_Sys_HHOO_NRT_SR = y.Inter_Sys_HHOO_NRT_SR,
Inter_Sys_HHO_RT_DR = y.Inter_Sys_HHO_RT_DR,
Inter_Sys_HHO_NRT_DR = y.Inter_Sys_HHO_NRT_DR,
Inc_IS_Change_Att = y.Inc_IS_Change_Att,
Intra_Sys_HHO_Att = y.Intra_Sys_HHO_Att,
Intra_Sys_HHO_SR = y.Intra_Sys_HHO_SR,
R99_Allo_DL_DCH_Cap_Data_Call = y.R99_Allo_DL_DCH_Cap_Data_Call,
R99_Allo_UL_DCH_Cap_Data_Call = y.R99_Allo_UL_DCH_Cap_Data_Call,
HSDSCH_Selections = y.HSDSCH_Selections,
HSDPA_Res_Acc_NRT = y.HSDPA_Res_Acc_NRT,
HSDPA_Res_Retain_NRT = y.HSDPA_Res_Retain_NRT,
HSDPA_Res_Retain_RT = y.HSDPA_Res_Retain_RT,
HSDPA_Attempt = y.HSDPA_Attempt,
HSDPA_SR = y.HSDPA_SR,
Avg_MAC_D_THP = y.Avg_MAC_D_THP,
Act_HSDSCH_MAC_D_THP_NW = y.Act_HSDSCH_MAC_D_THP_NW,
HSDPA_DL_DATA_Rcvd_NodeB = y.HSDPA_DL_DATA_Rcvd_NodeB,
HSDPA_MAC_HS_Data_Vol_at_RNC = y.HSDPA_MAC_HS_Data_Vol_at_RNC,
HSPDA_MAC_HS_Efficiency = y.HSPDA_MAC_HS_Efficiency,
HARQ_Non_Ack_Ratio_Mean = y.HARQ_Non_Ack_Ratio_Mean,
HSDPA_SCC_Att = y.HSDPA_SCC_Att,
E_DCH_Selections = y.E_DCH_Selections,
HSUPA_Res_Acc_NRT = y.HSUPA_Res_Acc_NRT,
HSUPA_Res_Retain_NRT = y.HSUPA_Res_Retain_NRT,
HSUPA_Res_Retain_RT = y.HSUPA_Res_Retain_RT,
HSUPA_Att = y.HSUPA_Att,
HSUPA_SR = y.HSUPA_SR,
HSUPA_MAC_es_Data_Vol_RNC = y.HSUPA_MAC_es_Data_Vol_RNC,
HSUPA_MAC_es_BLER = y.HSUPA_MAC_es_BLER,
E_DCH_HARQ_Non_Ack_Ratio = y.E_DCH_HARQ_Non_Ack_Ratio,
HSUPA_SCC_Att = y.HSUPA_SCC_Att,
AVG_CS_Traffic = y.AVG_CS_Traffic,
Inc_SMS_Att = y.Inc_SMS_Att
};
Chart1.DataSource = q;
Chart1.Series[0].XValueMember = "PeriodStartTime";
Chart1.Series[0].YValueMembers = HiddenFieldSeries1.Value.ToString();
Chart1.Series.Add(HiddenFieldSeries2.Value);
Chart1.Series[1].XValueMember = "PeriodstartTime2";
Chart1.Series[1].YValueMembers = HiddenFieldSeries2.Value.ToString();
}
}
Can We simplify Linq Select New codes?? while i only need 4 columns only.. :(
Your question dosen't make too much sense as far as your comments/labeling, so I took my best guess:
DDLLessons.DataSource = lesson;
DDLLessons.DataBind();
var query = from x in db.Scores
where x.StudentName == DDLStudentName.SelectedItem.Value
select new {
Day = x.Day,
Class = DDLLessons.SelectedItem.Value
};
Are you looking for selecting table name dynamically using strings (this is what I understood). If yes, have a look at this and select the table object from the string:
How can I dynamically select my Table at runtime with Dynamic LINQ
From the above link, this is what is relevant to you:
'' get the table from a type (which corresponds to a table in your database)
Dim typeName = "DatabaseTest.AdventureWorks." & tableName & ", DatabaseTest"
Dim entityType = Type.GetType(typeName)
Dim table = dc.GetTable(entityType)
Dim query As IQueryable = table
(credit for the code goes to original poster of the answer on the link that I've provided)
UPDATE: C# version of code:
// get the table from a type (which corresponds to a table in your database)
string typeName = "DatabaseTest.AdventureWorks." + tableName + ", DatabaseTest";
Type entityType = Type.GetType(typeName);
object table = dc.GetTable(entityType);
IQueryable query = table as IQueryable;